<template>
  <div class="teamFrom">
    <div class="header" v-if="viewType!='approval'">
      <p style="margin-right:30px"><strong>项目编号：</strong>{{projectBuildData.projectNo}}</p>
      <p style="margin-right:30px"><strong>项目名称：</strong>{{projectBuildData.projectName}}</p>
      <p v-if="btnShow&&(xChangePoint!=null||yChangePoint!=null||coreChangePoint!=null)" style="width: 50%;display: flex">
        <a-button type="primary" @click="convertToChangePoint" :loading="btnLoading">一键折算</a-button>
        <span>
          <img src="@/assets/attention-red.png" alt="" style="width:12px;margin-right: 5px;"/>
          <span style="font-size: 14px;">注：价值表或核心力值表变更，产生绩点变更的，可以一键折算，按原来分配的比例进行折算分配。如果原来没有分配的，需要手工重新分配。</span>
        </span>
      </p>
    </div>
    <div class="projectGoal">
      <ul class="Xgoal" v-show="xChangePoint!=null">
        <li  style="font-weight: bolder;">
          项目原绩点：
        </li>
        <li v-show="xChangePoint!=null" style="font-weight: bolder;margin-left: 80px;">
          变更后绩点：
        </li>
      </ul>
      <ul class="Xgoal" v-show="xPoint>0||xChangePoint!=null">
        <li>
          项目总X绩点：<span style="color: red;">{{xPoint}}</span>
        </li>
        <li v-show="xChangePoint!=null" style="margin-left: 80px;">
          项目总X绩点：<span style="color: red;">{{xChangePoint}}</span>
        </li>
        <li v-show="btnShow">
          已分配：<span>{{dispatchGradePointX}}</span>
        </li>
        <li v-show="btnShow">
          剩余：<span  style="color: orangered;">{{remainGradePointX}}</span>
        </li>
      </ul>
      <ul class="Ygoal" v-show="yPoint>0||yChangePoint!=null">
        <li>
          项目总Y绩点：<span style="color: red;">{{yPoint}}</span>
        </li>
        <li v-show="yChangePoint!=null"  style="margin-left: 80px;">
          项目总Y绩点：<span style="color: red;">{{yChangePoint}}</span>
        </li>
        <li v-show="btnShow">
          已分配：<span>{{dispatchGradePointY}}</span>
        </li>
        <li v-show="btnShow">
          剩余：<span  style="color: orangered;">{{remainGradePointY}}</span>
        </li>
      </ul>
      <ul class="Ygoal" v-show="corePoint>0||coreChangePoint!=null">
        <li>
          项目总核心力值：<span style="color: red;">{{corePoint}}</span>
        </li>
        <li v-show="coreChangePoint!=null"  style="margin-left: 80px;">
          项目总核心力值：<span style="color: red;">{{coreChangePoint}}</span>
        </li>
        <li v-show="btnShow">
          已分配：<span>{{dispatchGradePointCore}}</span>
        </li>
        <li v-show="btnShow">
          剩余：<span  style="color: orangered;">{{remainGradePointCore}}</span>
        </li>
      </ul>
      <ul class="Ygoal" v-if="false && projectBuildData.projectClass=='30'">
        <li style="display:flex;width:230px;align-items: center;">
          项目总成本(万元)：<span style="color: red;">{{totalManDays}}</span>
        </li>
        <li>
          <div style="display:flex;width:230px;align-items: center;"><span style="white-space: nowrap;">专委成本(万元)：</span><a-input v-model="projectBuildData.deptCost" type="number"></a-input></div>
        </li>
      </ul>

      <span style="font-size: 14px;color: orangered;" v-if="(corePoint>0||coreChangePoint!=null) && projectBuildData.projectTypeSubCategory == 'MA'">
        温馨提示：挖潜增效核心力值仅用于计算项目的价值乘数：价值乘数=挖潜增效核心力值/100</span>
    </div>
    <div class="content">
      <div class="title">
        <strong>主导项目的核心团队</strong>
      </div>
      <ul class="printGoal" v-if="projectBuildData.status===1">
        <li v-show="xPoint>0">
          <span>分配X绩点：</span>
          <a-input v-model="projectBuildData.teamGradePoint" @blur="checkGradePointDispatch(false)" style="width: 100px;"/>
        </li>
        <li v-show="xPoint>0&&btnShow">
          <span>剩余：</span>
          <span style="color: orangered;">{{remainData.remainTeamX}}</span>
        </li>
        <li v-show="yPoint>0">
          <span>分配Y绩点：</span>
          <a-input v-model="projectBuildData.teamGradePointBasic" @blur="checkGradePointDispatch(false)" style="width: 100px;"/>
        </li>
        <li v-show="yPoint>0&&btnShow">
          <span>剩余：</span>
          <span  style="color: orangered;">{{remainData.remainTeamY}}</span>
        </li>
        <li v-show="corePoint>0">
          <span>分配核心力值：</span>
          <a-input v-model="projectBuildData.teamGradePointCore" @blur="checkGradePointDispatch(false)" style="width: 100px;"/>
        </li>
        <li v-show="corePoint>0&&btnShow">
          <span>剩余：</span>
          <span  style="color: orangered;">{{remainData.remainTeamCore}}</span>
        </li>
        <li v-show="corePoint>0&&btnShow">
          <span>剩余：</span>
          <span  style="color: orangered;">{{remainData.remainTeamCore}}</span>
        </li>
<!--        <a-button class="default" v-if="projectBuildData.projectType == 'FA'" @click="importTeamMember">导入人天</a-button>-->
      </ul>
      <ul class="printGoal"  v-if="projectBuildData.status>1">
        <li v-show="xPoint>0||xChangePoint!=null">
          <span>分配X绩点：</span>
          <a-input v-model="projectBuildData.teamGradePointAudit" @blur="checkGradePointDispatchAudit(false)" style="width: 100px;"/>
        </li>
        <li v-show="(xPoint>0||xChangePoint!=null)&&btnShow">
          <span>剩余：</span>
          <span  style="color: orangered;">{{remainData.remainTeamX}}</span>
        </li>
        <li v-show="yPoint>0||yChangePoint!=null">
          <span>分配Y绩点：</span>
          <a-input v-model="projectBuildData.teamGradePointBasicAudit" @blur="checkGradePointDispatchAudit(false)" style="width: 100px;"/>
        </li>
        <li v-show="(yPoint>0||yChangePoint!=null)&&btnShow">
          <span>剩余：</span>
          <span  style="color: orangered;">{{remainData.remainTeamY}}</span>
        </li>
        <li v-show="corePoint>0||coreChangePoint!=null">
          <span>分配核心力值：</span>
          <a-input v-model="projectBuildData.teamGradePointCoreAudit" @blur="checkGradePointDispatchAudit(false)" style="width: 100px;"/>
        </li>
        <li v-show="(corePoint>0||coreChangePoint!=null)&&btnShow">
          <span>剩余：</span>
          <span  style="color: orangered;">{{remainData.remainTeamCore}}</span>
        </li>
        <a-button class="default" @click="exportTeamMember" :loading="exportLoading">导出</a-button>
        <a-button  v-if="projectBuildData.projectClass == '30'" class="default" @click="importMemberManday">导入成本</a-button>
        <a-button  v-if="projectBuildData.projectClass == '30'" class="default"  @click="handleFeedback" >查看成本</a-button>
      </ul>



      <div class="teamSelected">
        <div class="team-control" v-show="btnShow">
          <a-button type="primary" @click="addTeamMember">添加</a-button>
          <a-button class="default" @click="importTeamMember">导入</a-button>
          <a-button class="default" @click="exportTeamMember" :loading="exportLoading">导出</a-button>
          <a-button class="default" @click="delTeamMember">删除</a-button>
          <a-button class="default" @click="replaceTeamMember">一键替换</a-button>

          <template v-if="projectBuildData.projectClass=='30'">
            <a-button class="default" @click="sendInvitation" v-if="projectBuildData.status===1">发送邀约</a-button>
            <img src="@/assets/attention-red.png" alt="" style="width:12px;margin-right: 5px;" v-if="projectBuildData.status===1"/>
            <span style="font-size: 14px;" v-if="projectBuildData.status===1">注：非必填，对不确定项目参与意向的人员可以发出邀请，不会对经理或副经理发起邀请。</span>
          </template>
        </div>

        <a-table
          :scroll={x:true}
          :columns="teamList"
          :data-source="teamListData"
          bordered
          :pagination="false"
          :row-selection="{ selectedRowKeys: selectedTeamRowKeys, onChange: onSelectTeamChange }"
          rowKey="memberUserName"
        >
          <template slot="memberRoleName" slot-scope="text, record">
            <a-select style="width: 100%" v-model="record.memberRoleName" :options="roleOptions"></a-select>
          </template>
          <template slot="memberResponsibility" slot-scope="text, record">
            <a-textarea placeholder="请输入主要职责" auto-size v-model="record.memberResponsibility"/>
          </template>
          <template slot="memberGradePoint" slot-scope="text, record">
          <a-input placeholder="请输入X绩点" v-model="record.memberGradePoint" @blur="checkTeamX(record)"/>
        </template>
          <template slot="deptGradePoint" slot-scope="text, record">
            <a-input placeholder="请输入Y绩点" v-model="record.deptGradePoint" @blur="checkTeamY(record)"/>
          </template>
          <template slot="coreGradePoint" slot-scope="text, record">
            <a-input placeholder="请输入核心力值" v-model="record.coreGradePoint" @blur="checkTeamCore(record)"/>
          </template>
          <template slot="memberGradePointAudit" slot-scope="text, record">
            <a-input placeholder="请输入X绩点" v-model="record.memberGradePointAudit" @blur="checkTeamXAudit(record)"/>
          </template>
          <template slot="deptGradePointAudit" slot-scope="text, record">
            <a-input placeholder="请输入Y绩点" v-model="record.deptGradePointAudit" @blur="checkTeamYAudit(record)"/>
          </template>
          <template slot="coreGradePointAudit" slot-scope="text, record">
            <a-input placeholder="请输入核心力值" v-model="record.coreGradePointAudit" @blur="checkTeamCoreAudit(record)"/>
          </template>
           <!-- <template slot="manDays" slot-scope="text, record">
            <a-input placeholder="请输入成本" v-model="record.manDays" type="number"/>
          </template> -->
          <template slot="status" slot-scope="text, record">
            <span>{{!record.status||record.status===0?"未发起":record.status===1?'已发起':record.status===2?"应邀":'已拒绝'}}</span>
          </template>
        </a-table>
      </div>
    </div>
    <div class="content">
      <div class="title">
        <strong>协助模块</strong>
      </div>
      <ul class="printGoal"  v-if="projectBuildData.status===1">
        <li  v-show="xPoint>0">
          <span>分配X绩点：</span>
          <a-input v-model="projectBuildData.deptGradePoint" @blur="checkGradePointDispatch(false)" style="width: 100px;"/>
        </li>
        <li  v-show="xPoint>0&&btnShow">
          <span>剩余：</span>
          <span  style="color: orangered;">{{remainData.remainDeptX}}</span>
        </li>
        <li  v-show="yPoint>0">
          <span>分配Y绩点：</span>
          <a-input v-model="projectBuildData.deptGradePointBasic" @blur="checkGradePointDispatch(false)" style="width: 100px;"/>
        </li>
        <li  v-show="yPoint>0&&btnShow">
          <span>剩余：</span>
          <span  style="color: orangered;">{{remainData.remainDeptY}}</span>
        </li>
        <li  v-show="corePoint>0">
          <span>分配核心力值：</span>
          <a-input v-model="projectBuildData.deptGradePointCore" @blur="checkGradePointDispatch(false)" style="width: 100px;"/>
        </li>
        <li  v-show="corePoint>0&&btnShow">
          <span>剩余：</span>
          <span  style="color: orangered;">{{remainData.remainDeptCore}}</span>
        </li>
      </ul>
      <ul class="printGoal"  v-if="projectBuildData.status>1">
        <li  v-show="xPoint>0||xChangePoint!=null">
          <span>分配X绩点：</span>
          <a-input v-model="projectBuildData.deptGradePointAudit" @blur="checkGradePointDispatchAudit(false)" style="width: 100px;"/>
        </li>
        <li  v-show="(xPoint>0||xChangePoint!=null)&&btnShow">
          <span>剩余：</span>
          <span  style="color: orangered;">{{remainData.remainDeptX}}</span>
        </li>
        <li  v-show="yPoint>0||yChangePoint!=null">
          <span>分配Y绩点：</span>
          <a-input v-model="projectBuildData.deptGradePointBasicAudit" @blur="checkGradePointDispatchAudit(false)" style="width: 100px;"/>
        </li>
        <li  v-show="(yPoint>0||yChangePoint!=null)&&btnShow">
          <span>剩余：</span>
          <span  style="color: orangered;">{{remainData.remainDeptY}}</span>
        </li>
        <li  v-show="corePoint>0||coreChangePoint!=null">
          <span>分配核心力值：</span>
          <a-input v-model="projectBuildData.deptGradePointCoreAudit" @blur="checkGradePointDispatchAudit(false)" style="width: 100px;"/>
        </li>
        <li  v-show="(corePoint>0||coreChangePoint!=null)&&btnShow">
          <span>剩余：</span>
          <span  style="color: orangered;">{{remainData.remainDeptCore}}</span>
        </li>
      </ul>
      <div class="teamSelected">
        <div class="team-control" >
          <a-button v-show="btnShow" type="primary" @click="openSelectDept">添加</a-button>
          <a-button v-show="btnShow" class="default" @click="delDeptMember">删除</a-button>
          <img src="@/assets/attention-red.png" alt="" style="width:12px;margin-right: 5px;"/>
          <span style="font-size: 14px;">提醒：项目审批完毕会自动发送任务单给协助团队部门主管，如有附件给协助团队的，需一并上传，系统自动传送。</span>
        </div>
        <a-table
          :scroll={x:true}
          :columns="deptList"
          :data-source="deptListData"
          bordered
          :pagination="false"
          :row-selection="{ selectedRowKeys: selectedDeptRowKeys, onChange: onSelectDeptChange }"
          rowKey="rowKey"
        >
          <template slot="jobContent" slot-scope="text, record">
            <a-textarea placeholder="请输入工作内容" auto-size v-model="record.jobContent"/>
          </template>
          <template slot="deptName" slot-scope="text, record">
            <a-input placeholder="输入部门全称" v-model="record.deptName"/>
          </template>
          <template slot="leaderRealName" slot-scope="text, record">
            <span style="line-height: 30px;">{{record.leaderRealName}}</span>
            <a-button style="border: none;background-color:unset;margin:unset;width:auto;float: right;" size="small" @click="selectLeaderUser(record)" >➕</a-button>
          </template>
          <template slot="teamGradePoint" slot-scope="text, record">
            <a-input placeholder="输入X绩点" v-model="record.teamGradePoint" @blur="checkDeptX(record)"/>
          </template>
          <template slot="deptGradePoint" slot-scope="text, record">
            <a-input placeholder="输入Y绩点" v-model="record.deptGradePoint" @blur="checkDeptY(record)"/>
          </template>
          <template slot="coreGradePoint" slot-scope="text, record">
            <a-input placeholder="输入核心力值" v-model="record.coreGradePoint" @blur="checkDeptCore(record)"/>
          </template>
          <template slot="teamGradePointAudit" slot-scope="text, record">
            <a-input placeholder="输入X绩点" v-model="record.teamGradePointAudit" @blur="checkDeptXAudit(record)"/>
          </template>
          <template slot="deptGradePointAudit" slot-scope="text, record">
            <a-input placeholder="输入Y绩点" v-model="record.deptGradePointAudit" @blur="checkDeptYAudit(record)"/>
          </template>
          <template slot="coreGradePointAudit" slot-scope="text, record">
            <a-input placeholder="输入核心力值" v-model="record.coreGradePointAudit" @blur="checkDeptCoreAudit(record)"/>
          </template>
          <template slot="requiredCompletionTime" slot-scope="text, record">
            <a-date-picker size="small" v-model="record.requiredCompletionTime" valueFormat='YYYY-MM-DD' @change="requiredCompletionTimeChange(record)"/>
          </template>
          <template slot="toFile" slot-scope="text, record">
            <a-button type="default" @click="toFile(record)" :disabled="!record.fileBusId">附件&nbsp;<span style="size:10px;color:rgb(255, 116, 93);">({{record.fileAmount}})</span></a-button>
          </template>
        </a-table>
      </div>
    </div>
    <a-modal title="添加协助模块" :visible="showAddDept" @ok="doAddDept" @cancel="cancelAddDept">
      <ul class="info-list">
        <li style="margin-bottom: 20px;">
          <img src="@/assets/dbcircle.png" alt="">
          <span class="list-title">选择协助模块：</span>
          <a-select style="width: 200px;" v-model="selectAddDeptData" :options="deptOptions" :labelInValue="true"/>
        </li>
      </ul>
    </a-modal>
    <a-modal title="找合适的人才，为项目添砖加瓦" :visible="talentSearch.showAddTalent" @ok="doAddTalent" @cancel="cancelAddTalent" width="780px">
      <div>
        <a-row>
          <a-col :span="12">
            <div class="talent-title">
              <span >专业所属品类：</span>
            </div>
            <a-select style="width: 200px" :options="specialtyTypeOptions" @change="specialtyTypeChange"></a-select>
          </a-col>
          <a-col :span="12">
            <div class="talent-title">
              <span >专业/工序：</span>
            </div>
            <a-select style="width:200px" :options="specialtyOptions" mode="multiple" @change="specialtyChange"></a-select>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="12">
            <div class="talent-title">
              <span >专业技术模块：</span>
            </div>
            <a-select style="width: 200px" :options="specialtyTechnologyOptions" @change="specialtyTechnologyChange"></a-select>
          </a-col>
          <a-col :span="12">
            <div class="talent-title">
              <span >技术领域：</span>
            </div>
            <a-select style="width: 200px" :options="technologyOptions" mode="multiple" @change="technologyChange"></a-select>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="24">
            <div class="talent-title">
              <span >名称：</span>
            </div>
            <a-input style="width: 200px" placeholder="输入姓名精确查找" v-model="talentSearch.name" @pressEnter="searchTalent"/>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="24">
            <div  style="width: 100%;text-align: center;font-size: 13px;">
              <img src="@/assets/attention-red.png" alt="" style="width: 13px;margin-left: 5px;"/>
              <span>为了更好地找出合适的团队，专业技术品类、专业技术模块、团队姓名，三个条件至少填写一个条件才可以进入查询。</span>
            </div>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="24">
            <div style="width: 100%;text-align: center;">
              <a-button style="margin-right:15px;" class="default" @click="searchTalent">查询</a-button>
            </div>
          </a-col>
        </a-row>
        <a-table
          :scroll={x:true}
          :columns="talentSearch.talentColArr"
          :data-source="talentSearch.talentData"
          bordered
          :pagination="false"
          :row-selection="{ selectedRowKeys: talentSearch.selectedTalentRowKeys, onChange: onSelectTalentChange }"
          rowKey="username"
          width="100%"
        />
      </div>
    </a-modal>
    <a-modal class="selectedPerson" title="附件信息" :visible="attachVisible" width="80vw" @cancel="handleAttachClose()" :footer="null" :destroyOnClose="true">
      <attach-tab :project-build-id="projectBuildId" :project-class="projectBuildData.projectClass" bus-field="projectDept" :bus-key="changeId ? fileBusId+'_'+changeId : fileBusId" :bus-type="projectBuildId" :change-id="changeId"  @closeAttachModal="handleAttachClose()"></attach-tab>
    </a-modal>
    <person-select ref="personSelect" @setPersonSelResult="setPersonSelResult" :limit="personLimit"/>
    <!--导入团队成员-->
    <excel-paste :columnsExcel="columnsExcel"
                 :exportXlsTemplateUrl="exportXlsTemplateUrl"
                 :exportXlsTemplateRequestUrl="exportXlsTemplateRequestUrl"
                 :excelVisible="excelVisible" :excelConfirmLoading="excelConfirmLoading"   @handleOkExcel="handleOkExcel" @handleCancelExcel="handleCancelExcel"></excel-paste>
<!--    <excel-paste :columnsExcel="columnsExcel" :exportXlsTemplateUrl="exportXlsTemplateUrl" :exportXlsTemplateRequestUrl="exportXlsTemplateRequestUrl" :excelVisible="excelVisible" :excelConfirmLoading="excelConfirmLoading"   @handleOkExcel="handleOkExcel" @handleCancelExcel="handleCancelExcel"></excel-paste>-->
    <manday-modal ref="mandayRef" :projectBuildId="projectBuildId">

    </manday-modal>
  </div>
</template>
<script>
  import Vue from 'vue'
  import { USER_NAME } from "@/store/mutation-types"
  import { httpAction, getAction,postAction ,postActionAsync,downloadFileLink} from '@/api/manage'
  import ARow from "ant-design-vue/es/grid/Row";
  import ACol from "ant-design-vue/es/grid/Col";
  import ExcelPaste from '@/components/excelPaste/ExcelPaste'
  import LuckSheetPaste from '@/components/excelPaste/LuckSheetPaste'
  import {getActionAsync} from "../../api/manage";
  import { Modal } from 'ant-design-vue'
  import MandayModal from '@/views/projectBuildStup/modules/MandayModal.vue'
export default {
  components: {
    ACol, ARow,
    ExcelPaste,
    LuckSheetPaste ,
    MandayModal ,
    PersonSelect: () => import('@/components/tools/PersonSelect'),
    AttachTab: () => import('@/components/tools/projectBuildStup/AttachTab')
  },
  props:{
    viewType:{
      Type: String,
      default: ''
    }
  },
  data () {
    return {
      xPoint:0,
      yPoint:0,
      corePoint:0,
      xChangePoint:null,
      yChangePoint:null,
      coreChangePoint:null,
      loadingDone:false,
      btnShow:false,
      btnLoading:false,
      showAddDept:false,
      currentUserId: Vue.ls.get(USER_NAME),
      projectBuildId: this.$route.query.projectBuildId,
      changeId: this.$route.query.changeId,
      currentAudit:this.$route.query.currentAudit,
      changeFlag:this.$route.query.changeFlag=='true' ? true :false,
      canDoSave: this.$route.query.canDoSave=='true' ? true : false,
      projectRewardApplyId:this.$route.query.projectRewardApplyId,
      projectBuildData:{projectNo:'',projectName:''},
      dispatchGradePointX:0,
      dispatchGradePointY:0,
      dispatchGradePointCore:0,
      remainGradePointX:0,
      remainGradePointY:0,
      remainGradePointCore:0,
      remainData:{
        remainTeamX:0,
        remainTeamY:0,
        remainTeamCore:0,
        remainDeptX:0,
        remainDeptY:0,
        remainDeptCore:0,
      },
      teamListData:[],
      deptListData:[],
      deptRowKey:0,
      typeTeamData:null,
      deptOptions:[],
      roleOptions:[],
      responsibilityOptions:[],
      specialtyTypeOptions:[],
      specialtyOptions:[],
      specialtyTechnologyOptions:[],
      technologyOptions:[],
      teamGpaData:null,
      managerGpaData:null,
      countModeData:null,
      projectChangeData:null,
      changeTarget:4,
      url:{
        queryBuildById:'/projectBuild/getNormalVo',
        queryListByBuildId:'/projectBuildTeam/queryTeamListByBuildId',
        queryDeptListByBuildId:'/projectBuildTeam/queryDeptListByBuildId',
        queryTeamCodeInfo:'/projectBuildTeam/queryTeamCodeInfo',
        saveTeam:'/projectBuildTeam/saveTeam',
        addBatch:'/projectBuildTeam/importTeam',
        importMandays:'/projectBuildManday/importMandays',
        sendInvitation:'/projectBuildTeam/sendInvitation',
        queryTeamGpaByProjectType:'/teamGPAScale/queryProjectType',
        queryChangeByBuildId:'/projectChange/queryByBuildId',
        queryChangeById:"/projectChange/queryById",
        queryChangeDetailById:'/projectChange/queryDetailByBuildId',
        saveChangeTeam:'/projectChange/saveChangeTeam',
        importChangeTeam:'/projectChange/importChangeTeam',
        convertToChangePoint:'/projectChange/convertToChangePoint',

        getAttaches: '/tp/attach/getAttaches'
      },
      teamList:[],
      teamAddList : [
        { title: '团队成员', width:'100px',align:'left',dataIndex: 'memberRealName', key: 'memberRealName' },
        { title: '所在部门', width:'100px',align:'left',dataIndex: 'memberDeptName', key: 'memberDeptName'},
        { title: '角色', width:'15%',align:'left',dataIndex: 'memberRoleName', key: 'memberRoleName',scopedSlots: { customRender: 'memberRoleName' }},
        { title: '主要职责', width:'190px',align:'left',dataIndex: 'memberResponsibility', key: 'memberResponsibility',scopedSlots: { customRender: 'memberResponsibility' } },
        // { title: '邀约状态', width:'90px',align:'left',dataIndex: 'status', key: 'status' ,scopedSlots: { customRender: 'status' }}
      ],
      teamAuditList : [
        { title: '团队成员', width:'100px',align:'left',dataIndex: 'memberRealName', key: 'memberRealName' },
        { title: '所在部门', width:'100px',align:'left',dataIndex: 'memberDeptName', key: 'memberDeptName'},
        { title: '角色', width:'18%',align:'left',dataIndex: 'memberRoleName', key: 'memberRoleName',scopedSlots: { customRender: 'memberRoleName' }},
        { title: '主要职责', width:'190px',align:'left',dataIndex: 'memberResponsibility', key: 'memberResponsibility',scopedSlots: { customRender: 'memberResponsibility' } },

      ],
      // manDaysList:[
      //   { title: '成本(万元)', width:'190px',align:'left',dataIndex: 'manDays', key: 'manDays',scopedSlots: { customRender: 'manDays' } },
      // ],
      deptList : [],
      deptAddList : [
        { title: '协作模块', width:'120px',align:'left',dataIndex: 'projectTeamName', key: 'projectTeamName' },
        { title: '具体部门', width:'220px',align:'left',dataIndex: 'deptName', key: 'deptName',scopedSlots: { customRender: 'deptName' }},
        { title: '具体工作内容和输出材料要求', width:'320px',align:'left',dataIndex: 'jobContent', key: 'jobContent',scopedSlots: { customRender: 'jobContent' }},
        { title: '部门主管', width:'120px',align:'left',dataIndex: 'leaderRealName', key: 'leaderRealName',scopedSlots: { customRender: 'leaderRealName' } },

      ],
      deptAuditList : [
        { title: '协作模块', width:'120px',align:'left',dataIndex: 'projectTeamName', key: 'projectTeamName' },
        { title: '具体部门', width:'220px',align:'left',dataIndex: 'deptName', key: 'deptName',scopedSlots: { customRender: 'deptName' }},
        { title: '具体工作内容和输出材料要求', width:'320px', align:'left',dataIndex: 'jobContent', key: 'jobContent',scopedSlots: { customRender: 'jobContent' }},
        { title: '部门主管', width:'120px',align:'left',dataIndex: 'leaderRealName', key: 'leaderRealName',scopedSlots: { customRender: 'leaderRealName' } },

      ],
      selectAddDeptData:{},
      selectedTeamRowKeys:[],
      selectedDeptRowKeys:[],
      userSel: {
        tabUrl: '/upms/user/selPersonList',
        title:'',
        visible: false,
        confirmLoading: true,
        keyword: '',
        userSelectData:[],
        data: [],
        freshKey: 0,
        selectUserData:[],
        currentRecord:null,
        selectPersonType:'',
        selectItem:null
      },
      personLimit:0,
      talentSearch:{
        showAddTalent:false,
        codeInfoUrl:"/manage/codeInfo/queryByType",
        searchTalentUrl:"/upms/user/listWithCondition",
        specialtyType:"",
        specialtyTechnology:'',
        specialty:null,
        technology:null,
        name:'',
        talentColArr:[
          { title: '姓名', width:'45%',align:'left',dataIndex: 'realname', key: 'realname' },
          { title: '部门', width:'45%',align:'left',dataIndex: 'deptName', key: 'deptName' },
        ],
        talentData:[],
        selectedTalentRowKeys:[],
        selectedTalentRows:[]
      },

      columnsExcelManday:[
        {
          title: '序号',
          dataIndex: '',
          key:'rowIndex',
          width:60,
          align:"center",
          customRender:function (t,r,index) {
            return parseInt(index)+1;
          },
          isImportExcelColumns:false
        } ,
        {
          title:'团队成员',
          align:"center",
          dataIndex: 'memberRealName'
        },
        {
          title:'团队成员账号',
          align:"center",
          dataIndex: 'memberUserName'
        },

        {
          title:'本月投入(万元)',
          align:"center",
          dataIndex: 'manDays'
        }

      ] ,
      columnsExcel:[
        {
          title: '序号',
          dataIndex: '',
          key:'rowIndex',
          width:60,
          align:"center",
          customRender:function (t,r,index) {
            return parseInt(index)+1;
          },
          isImportExcelColumns:false
        },


        {
          title:'成员账号',
          align:"center",
          dataIndex: 'memberUserName'
        },
        {
          title:'角色',
          align:"center",
          dataIndex: 'memberRoleName'
        },
        {
          title:'主要职责',
          align:"center",
          dataIndex: 'memberResponsibility'
        },
        {
          title:'X绩点',
          align:"center",
          dataIndex: 'memberGradePoint'
        },
        {
          title:'Y绩点',
          align:"center",
          dataIndex: 'deptGradePoint'
        },
        {
          title:'核心力值',
          align:"center",
          dataIndex: 'coreGradePoint'
        }
      ],
      excelVisible:false,
      excelConfirmLoading:false,
      excelDataSource:[],
      exportXlsTemplateUrl:'templates/excel/团队表导入模板.xls',
      exportXlsTemplateRequestUrl:"/common/exportXlsTemplate",
      attachVisible:false,

      saveType: 1 ,
      fileBusId:'',
      exportLoading:false,
    }
  },
  computed: {
    hasSelected() {
      return this.selectedRowKeys.length > 0;
    },
    totalManDays(){
      let temp = 0
      if(this.teamListData && this.teamListData.length>0){
        this.teamListData.forEach(t=>{
          if(t.manDays && !isNaN(t.manDays)){
            temp+=parseFloat(t.manDays)
          }
        })
      }
      return temp.toFixed(1);
    }
  },
  watch:{
    // projectBuildData:function(){
    //   this.checkGradePointDispatch();
    // }
  },
  mounted () {
    this.getProjectBuildData();
    // this.getTeamListData();
    // this.getDeptListData();
    // this.getSelUserData();
    this.btnShow=this.canDoSave;
  },
  methods: {
    freshFileAmounts(){
      var vm=this;
      var listData = this.deptListData;
      this.deptListData = [];
      listData.forEach(data=>{
        var busField = this.changeId ? 'projectDeptChange' : 'projectDept';
        var busKey = this.changeId ? data.fileBusId+'_'+this.changeId : data.fileBusId;
        getAction(this.url.getAttaches,{dbKey:'Trd',busKey:busKey,busField:busField,busType:this.projectBuildId}).then(res=>{
          if(res.code==1 && res.data!=null){
            data.fileAmount = res.data.length
          }
          vm.deptListData.push(data);
        })
      });

    },
    handleAttachClose(){
      this.attachVisible=false;
      this.freshFileAmounts();
    },
    requiredCompletionTimeChange:function(record){
      var now = new Date();
      var change = record.requiredCompletionTime;
      if(!change){
        return
      }
      var changeArr = change.split('-');
      var year = parseInt(changeArr[0]);
      var month = this.getMonthOrDay(changeArr[1])-1
      var day = this.getMonthOrDay(changeArr[2])
      var changeDate = new Date(year,month,day,23,59,59)
      if(now>changeDate){
        record.requiredCompletionTime=null
        this.$message.warning('要求完成时间不能小于当前日期')
      }
    },
    getMonthOrDay(val){
      val=String(val);
      return parseInt(val.startsWith('0') ? val.slice(1) : val);
    },
    toFile(record){
      this.fileBusId=record.fileBusId
      this.attachVisible=true
    },
    getProjectBuildData:function(){
      //debugger;
      getAction(this.url.queryBuildById,{id:this.projectBuildId}).then(res=>{
        debugger
        this.projectBuildData=res.result||{};
        /*this.btnShow=(this.projectBuildData.status===1||this.currentAudit==='true')&&(this.projectBuildData.createUserId===this.currentUserId||this.projectBuildData.projectManagers.indexOf(this.currentUserId)>=0||
          this.projectBuildData.assistantProjectManagers.indexOf(this.currentUserId)>=0);
        if(this.changeId&&
          (this.projectBuildData.createUserId === this.currentUserId ||
            this.projectBuildData.projectManagers.indexOf(this.currentUserId) >= 0 ||
            this.projectBuildData.assistantProjectManagers.indexOf(this.currentUserId) >= 0)||
          (/!*this.projectBuildData.projectClass=='40'&&*!/this.projectBuildData.projectMembers.indexOf(this.currentUserId)>=0)){
          this.btnShow =true;
        }*/
        //信息技术类添加邀约

        if(this.projectBuildData.projectClass=='30'){
          //  this.teamAddList.push(this.manDaysList[0]);
          // this.teamAuditList.push(this.manDaysList[0])
          this.teamAddList.push({ title: '邀约状态', width:'90px',align:'left',dataIndex: 'status', key: 'status' ,scopedSlots: { customRender: 'status' }})
        }

        this.projectBuildData.projectGradePoint=this.projectBuildData.projectGradePoint?this.projectBuildData.projectGradePoint:0;
        this.projectBuildData.projectGradePointBasic=this.projectBuildData.projectGradePointBasic?this.projectBuildData.projectGradePointBasic:0;
        this.projectBuildData.projectGradePointCore=this.projectBuildData.projectGradePointCore?this.projectBuildData.projectGradePointCore:0;
        this.projectBuildData.projectAuditGradePoint=this.projectBuildData.projectAuditGradePoint?this.projectBuildData.projectAuditGradePoint:0;
        this.projectBuildData.projectAuditGradePointBasic=this.projectBuildData.projectAuditGradePointBasic?this.projectBuildData.projectAuditGradePointBasic:0;
        this.projectBuildData.projectAuditGradePointCore=this.projectBuildData.projectAuditGradePointCore?this.projectBuildData.projectAuditGradePointCore:0;
        this.xPoint=this.projectBuildData.status>1?this.projectBuildData.projectAuditGradePoint:this.projectBuildData.projectGradePoint;
        this.yPoint=this.projectBuildData.status>1?this.projectBuildData.projectAuditGradePointBasic:this.projectBuildData.projectGradePointBasic;
        this.corePoint=this.projectBuildData.status>1?this.projectBuildData.projectAuditGradePointCore:this.projectBuildData.projectGradePointCore;
        if(this.projectBuildData.status===1){
          this.projectBuildData.teamGradePoint=res.result.teamGradePoint&&this.xPoint>0?res.result.teamGradePoint:0;
          this.projectBuildData.teamGradePointBasic=res.result.teamGradePointBasic&&this.yPoint>0?res.result.teamGradePointBasic:0;
          this.projectBuildData.teamGradePointCore=res.result.teamGradePointCore&&this.corePoint>0?res.result.teamGradePointCore:0;
          this.projectBuildData.deptGradePoint=res.result.deptGradePoint&&this.xPoint>0?res.result.deptGradePoint:0;
          this.projectBuildData.deptGradePointBasic=res.result.deptGradePointBasic&&this.yPoint>0?res.result.deptGradePointBasic:0;
          this.projectBuildData.deptGradePointCore=res.result.deptGradePointCore&&this.corePoint>0?res.result.deptGradePointCore:0;
          this.checkGradePointDispatch(false);
          this.teamList=this.teamAddList;
          this.deptList=this.deptAddList;
        }else{
          if(!this.changeId){
            this.projectBuildData.teamGradePointAudit=res.result.teamGradePointAudit&&this.xPoint>0?res.result.teamGradePointAudit:0;
            this.projectBuildData.teamGradePointBasicAudit=res.result.teamGradePointBasicAudit&&this.yPoint>0?res.result.teamGradePointBasicAudit:0;
            this.projectBuildData.teamGradePointCoreAudit=res.result.teamGradePointCoreAudit&&this.corePoint>0?res.result.teamGradePointCoreAudit:0;
            this.projectBuildData.deptGradePointAudit=res.result.deptGradePointAudit&&this.xPoint>0?res.result.deptGradePointAudit:0;
            this.projectBuildData.deptGradePointBasicAudit=res.result.deptGradePointBasicAudit&&this.yPoint>0?res.result.deptGradePointBasicAudit:0;
            this.projectBuildData.deptGradePointCoreAudit=res.result.deptGradePointCoreAudit&&this.corePoint>0?res.result.deptGradePointCoreAudit:0;
            this.checkGradePointDispatchAudit(false);
          }
          this.teamList=this.teamAuditList;
          this.deptList=this.deptAuditList;
        }

        if(this.changeId){
          this.getProjectChangeData();
        }else{
          this.handleGradeShow();
          this.getTeamListData();
          // this.getDeptListData();
        }
        this.getTypeTeamData();
        this.getTeamGpaData();
        this.getCountModeData();
      })

    },
    handleGradeShow(){
      //最终展示的x/y/core绩点
      if(this.xPoint>0||this.xChangePoint!=null){
        this.teamAddList.push({ title: '分配X绩点', width:'100px',align:'left',dataIndex: 'memberGradePoint', key: 'memberGradePoint' ,scopedSlots: { customRender: 'memberGradePoint' }});
        this.teamAuditList.push({ title: '分配X绩点', width:'100px',align:'left',dataIndex: 'memberGradePointAudit', key: 'memberGradePointAudit' ,scopedSlots: { customRender: 'memberGradePointAudit' }});
        this.deptAddList.push({ title: '分配X绩点', width:'100px',align:'left',dataIndex: 'teamGradePoint', key: 'teamGradePoint' ,scopedSlots: { customRender: 'teamGradePoint' }});
        this.deptAuditList.push({ title: '分配X绩点', width:'100px',align:'left',dataIndex: 'teamGradePointAudit', key: 'teamGradePointAudit' ,scopedSlots: { customRender: 'teamGradePointAudit' }});
      }
      if(this.yPoint>0||this.yChangePoint!=null){
        this.teamAddList.push({ title: '分配Y绩点', width:'100px',align:'left',dataIndex: 'deptGradePoint', key: 'deptGradePoint' ,scopedSlots: { customRender: 'deptGradePoint' }});
        this.teamAuditList.push({ title: '分配Y绩点', width:'100px',align:'left',dataIndex: 'deptGradePointAudit', key: 'deptGradePointAudit' ,scopedSlots: { customRender: 'deptGradePointAudit' }});
        this.deptAddList.push({ title: '分配Y绩点', width:'100px',align:'left',dataIndex: 'deptGradePoint', key: 'deptGradePoint' ,scopedSlots: { customRender: 'deptGradePoint' }});
        this.deptAuditList.push({ title: '分配Y绩点', width:'100px',align:'left',dataIndex: 'deptGradePointAudit', key: 'deptGradePointAudit' ,scopedSlots: { customRender: 'deptGradePointAudit' }});
      }
      if(this.corePoint>0||this.coreChangePoint!=null){
        this.teamAddList.push({ title: '分配核心力值', width:'100px',align:'left',dataIndex: 'coreGradePoint', key: 'coreGradePoint' ,scopedSlots: { customRender: 'coreGradePoint' }});
        this.teamAuditList.push({ title: '分配核心力值', width:'100px',align:'left',dataIndex: 'coreGradePointAudit', key: 'coreGradePointAudit' ,scopedSlots: { customRender: 'coreGradePointAudit' }});
        this.deptAddList.push({ title: '分配核心力值', width:'100px',align:'left',dataIndex: 'coreGradePoint', key: 'coreGradePoint' ,scopedSlots: { customRender: 'coreGradePoint' }});
        this.deptAuditList.push({ title: '分配核心力值', width:'100px',align:'left',dataIndex: 'coreGradePointAudit', key: 'coreGradePointAudit' ,scopedSlots: { customRender: 'coreGradePointAudit' }});
      }
      var requiredCompletionTime={ title: '要求完成时间', width:'145px',align:'left',dataIndex: 'requiredCompletionTime', key: 'requiredCompletionTime',scopedSlots: { customRender: 'requiredCompletionTime' } }
      var toFileColumn={ title: '附件信息', width:'90px',dataIndex: 'fileBusId', key: 'fileBusId',scopedSlots: { customRender: 'toFile' } }
      this.deptAddList.push(requiredCompletionTime);
      this.deptAuditList.push(requiredCompletionTime);
      this.deptAddList.push(toFileColumn);
      this.deptAuditList.push(toFileColumn);
    },
    getProjectChangeData(){
      getAction(this.url.queryChangeById,{id:this.changeId}).then(async res=>{
        if(res.result){
          // this.btnShow=(this.projectBuildData.createUserId===this.currentUserId||this.projectBuildData.projectManagers.indexOf(this.currentUserId)>=0||
          //   this.projectBuildData.assistantProjectManagers.indexOf(this.currentUserId)>=0||
          //   (/*this.projectBuildData.projectClass=='40'&&*/this.projectBuildData.projectMembers.indexOf(this.currentUserId)>=0))&&res.result.status===1;
          this.projectChangeData=res.result;
          await this.getChangeXYGradePoint();
          await this.getChangeCoreGradePoint();
          if(this.xChangePoint!=null||this.yChangePoint!=null||this.coreChangePoint!=null){
            this.xChangePoint=this.xChangePoint!=null?this.xChangePoint:this.xPoint;
            this.yChangePoint=this.yChangePoint!=null?this.yChangePoint:this.yPoint;
            this.coreChangePoint=this.coreChangePoint!=null?this.coreChangePoint:this.corePoint;
          }
          this.handleGradeShow();
          this.getChangeTeamData();
        }
      })
    },
    async getChangeXYGradePoint(){
      await getActionAsync(this.url.queryChangeDetailById,{changeId:this.changeId,changeTarget:5}).then(res=>{
        if(res.result){
          res.result.projectGradePoint=res.result.projectGradePoint?res.result.projectGradePoint:0;
          res.result.projectGradePointBasic=res.result.projectGradePointBasic?res.result.projectGradePointBasic:0;
          if(this.xPoint!==res.result.projectGradePoint){
            this.xChangePoint=res.result.projectGradePoint;
          }
          if(this.yPoint!==res.result.projectGradePointBasic){
            this.yChangePoint=res.result.projectGradePointBasic;
          }
        }
      })
    },
    async getChangeCoreGradePoint(){
      await getActionAsync(this.url.queryChangeDetailById,{changeId:this.changeId,changeTarget:6}).then(res=>{
        if(res.result){
          res.result.projectGradePointCore=res.result.projectGradePointCore?res.result.projectGradePointCore:0;
          if(this.corePoint!==res.result.projectGradePointCore){
            this.coreChangePoint=res.result.projectGradePointCore;
          }
        }
      })
    },
    getChangeTeamData(){
      const that=this;
      getAction(this.url.queryChangeDetailById,{changeId:this.changeId,changeTarget:this.changeTarget}).then(res=>{
        if(res.result){
          this.projectBuildData.teamGradePointAudit=res.result.teamGradePointAudit&&(this.xPoint>0||this.xChangePoint!=null)?res.result.teamGradePointAudit:0;
          this.projectBuildData.teamGradePointBasicAudit=res.result.teamGradePointBasicAudit&&(this.yPoint>0||this.yChangePoint!=null)?res.result.teamGradePointBasicAudit:0;
          this.projectBuildData.teamGradePointCoreAudit=res.result.teamGradePointCoreAudit&&(this.corePoint>0||this.coreChangePoint!=null)?res.result.teamGradePointCoreAudit:0;
          this.projectBuildData.deptGradePointAudit=res.result.deptGradePointAudit&&(this.xPoint>0||this.xChangePoint!=null)?res.result.deptGradePointAudit:0;
          this.projectBuildData.deptGradePointBasicAudit=res.result.deptGradePointBasicAudit&&(this.yPoint>0||this.yChangePoint!=null)?res.result.deptGradePointBasicAudit:0;
          this.projectBuildData.deptGradePointCoreAudit=res.result.deptGradePointCoreAudit&&(this.corePoint>0||this.coreChangePoint!=null)?res.result.deptGradePointCoreAudit:0;
          this.checkGradePointDispatchAudit(false);
          let teamData=res.result.teamList;
          teamData.forEach(function(item){
            item.memberGradePointAudit=item.memberGradePointAudit&&(that.xPoint>0||that.xChangePoint!=null)?item.memberGradePointAudit:0;
            item.deptGradePointAudit=item.deptGradePointAudit&&(that.yPoint>0||that.yChangePoint!=null)?item.deptGradePointAudit:0;
            item.coreGradePointAudit=item.coreGradePointAudit&&(that.corePoint>0||that.coreChangePoint!=null)?item.coreGradePointAudit:0;
          });
          this.teamListData=teamData;
          this.countTeamRemain();
          // this.deptListData=res.result.deptList;
          let deptData=res.result.deptList||[];
          deptData.forEach(function(item,index){
            item.rowKey=index;
            that.deptRowKey=index;
            item.teamGradePointAudit=item.teamGradePointAudit&&(that.xPoint>0||that.xChangePoint!=null)?item.teamGradePointAudit:0;
            item.deptGradePointAudit=item.deptGradePointAudit&&(that.yPoint>0||that.yChangePoint!=null)?item.deptGradePointAudit:0;
            item.coreGradePointAudit=item.coreGradePointAudit&&(that.corePoint>0||that.coreChangePoint!=null)?item.coreGradePointAudit:0;
          });
          this.deptListData=deptData;
          this.countDeptRemain();
          this.loadingDone=true;
          this.freshFileAmounts();
        }else{
          this.getTeamListData();
          // this.getDeptListData();
        }
      })
    },
    getTeamListData:function(){
      const that=this;
      getAction(this.url.queryListByBuildId,{projectBuildId:this.projectBuildId}).then(res=>{
        let teamData=res.result||[];
        teamData.forEach(function(item){
          if(that.projectBuildData.status>1){
            item.memberGradePointAudit=item.memberGradePointAudit&&that.xPoint>0?item.memberGradePointAudit:0;
            item.deptGradePointAudit=item.deptGradePointAudit&&that.yPoint>0?item.deptGradePointAudit:0;
            item.coreGradePointAudit=item.coreGradePointAudit&&that.corePoint>0?item.coreGradePointAudit:0;
          }else{
            item.memberGradePoint=item.memberGradePoint&&that.xPoint>0?item.memberGradePoint:0;
            item.deptGradePoint=item.deptGradePoint&&that.yPoint>0?item.deptGradePoint:0;
            item.coreGradePoint=item.coreGradePoint&&that.corePoint>0?item.coreGradePoint:0;
          }
        });
        this.teamListData=teamData;
        this.countTeamRemain();
        this.getDeptListData();
      })
    },
    countTeamRemain(){
      const that=this;
      let totalX=0,totalY=0,totalCore=0;
      this.teamListData.forEach(function(item){
        if(!item.status||item.status<3){
          if(that.projectBuildData.status===1){
            totalX+=!item.memberGradePoint||item.memberGradePoint===''?0:parseFloat(item.memberGradePoint);
            totalY+=!item.deptGradePoint||item.deptGradePoint===''?0:parseFloat(item.deptGradePoint);
            totalCore+=!item.coreGradePoint||item.coreGradePoint===''?0:parseFloat(item.coreGradePoint);
          }else{
            totalX+=!item.memberGradePointAudit||item.memberGradePointAudit===''?0:parseFloat(item.memberGradePointAudit);
            totalY+=!item.deptGradePointAudit||item.deptGradePointAudit===''?0:parseFloat(item.deptGradePointAudit);
            totalCore+=!item.coreGradePointAudit||item.coreGradePointAudit===''?0:parseFloat(item.coreGradePointAudit);
          }
        }
      });
      if(this.projectBuildData.status===1){
        this.remainData.remainTeamX=parseFloat(this.projectBuildData.teamGradePoint)-totalX;
        this.remainData.remainTeamY=parseFloat(this.projectBuildData.teamGradePointBasic)-totalY;
        this.remainData.remainTeamCore=parseFloat(this.projectBuildData.teamGradePointCore)-totalCore;
      }else{
        this.remainData.remainTeamX=parseFloat(this.projectBuildData.teamGradePointAudit)-totalX;
        this.remainData.remainTeamY=parseFloat(this.projectBuildData.teamGradePointBasicAudit)-totalY;
        this.remainData.remainTeamCore=parseFloat(this.projectBuildData.teamGradePointCoreAudit)-totalCore;
      }
      this.remainData.remainTeamX=this.remainData.remainTeamX.toFixed(2)<0?'超出'+(-this.remainData.remainTeamX.toFixed(2)):Math.abs(this.remainData.remainTeamX).toFixed(2);
      this.remainData.remainTeamY=this.remainData.remainTeamY.toFixed(2)<0?'超出'+(-this.remainData.remainTeamY.toFixed(2)):Math.abs(this.remainData.remainTeamY).toFixed(2);
      this.remainData.remainTeamCore=this.remainData.remainTeamCore.toFixed(2)<0?'超出'+(-this.remainData.remainTeamCore.toFixed(2)):Math.abs(this.remainData.remainTeamCore).toFixed(2);
    },
    getDeptListData:function(){
      const that=this;
      getAction(this.url.queryDeptListByBuildId,{projectBuildId:this.projectBuildId}).then(res=>{
        let deptData=res.result||[];
        deptData.forEach(function(item,index){
          item.rowKey=index;
          that.deptRowKey=index;
          if(that.projectBuildData.status>1){
            item.teamGradePointAudit=item.teamGradePointAudit&&that.xPoint>0?item.teamGradePointAudit:0;
            item.deptGradePointAudit=item.deptGradePointAudit&&that.yPoint>0?item.deptGradePointAudit:0;
            item.coreGradePointAudit=item.coreGradePointAudit&&that.corePoint>0?item.coreGradePointAudit:0;
          }else{
            item.teamGradePoint=item.teamGradePoint&&that.xPoint>0?item.teamGradePoint:0;
            item.deptGradePoint=item.deptGradePoint&&that.yPoint>0?item.deptGradePoint:0;
            item.coreGradePoint=item.coreGradePoint&&that.corePoint>0?item.coreGradePoint:0;
          }
        });
        this.deptListData=deptData;

        this.countDeptRemain();
        this.freshFileAmounts();
        this.loadingDone=true;
      })
    },
    countDeptRemain(){
      const that=this;
      let totalX=0,totalY=0,totalCore=0;
      this.deptListData.forEach(function(item){
        if(that.projectBuildData.status===1){
          totalX+=!item.teamGradePoint||item.teamGradePoint===''?0:parseFloat(item.teamGradePoint);
          totalY+=!item.deptGradePoint||item.deptGradePoint===''?0:parseFloat(item.deptGradePoint);
          totalCore+=!item.coreGradePoint||item.coreGradePoint===''?0:parseFloat(item.coreGradePoint);
        }else{
          totalX+=!item.teamGradePointAudit||item.teamGradePointAudit===''?0:parseFloat(item.teamGradePointAudit);
          totalY+=!item.deptGradePointAudit||item.deptGradePointAudit===''?0:parseFloat(item.deptGradePointAudit);
          totalCore+=!item.coreGradePointAudit||item.coreGradePointAudit===''?0:parseFloat(item.coreGradePointAudit);
        }

      });
      if(this.projectBuildData.status===1) {
        this.remainData.remainDeptX = parseFloat(this.projectBuildData.deptGradePoint) - totalX;
        this.remainData.remainDeptY = parseFloat(this.projectBuildData.deptGradePointBasic) - totalY;
        this.remainData.remainDeptCore = parseFloat(this.projectBuildData.deptGradePointCore) - totalCore;
      }else{
        this.remainData.remainDeptX = parseFloat(this.projectBuildData.deptGradePointAudit) - totalX;
        this.remainData.remainDeptY = parseFloat(this.projectBuildData.deptGradePointBasicAudit) - totalY;
        this.remainData.remainDeptCore = parseFloat(this.projectBuildData.deptGradePointCoreAudit) - totalCore;
      }
      this.remainData.remainDeptX=this.remainData.remainDeptX.toFixed(2)<0?'超出'+(-this.remainData.remainDeptX.toFixed(2)):Math.abs(this.remainData.remainDeptX).toFixed(2);
      this.remainData.remainDeptY=this.remainData.remainDeptY.toFixed(2)<0?'超出'+(-this.remainData.remainDeptY.toFixed(2)):Math.abs(this.remainData.remainDeptY).toFixed(2);
      this.remainData.remainDeptCore=this.remainData.remainDeptCore.toFixed(2)<0?'超出'+(-this.remainData.remainDeptCore.toFixed(2)):Math.abs(this.remainData.remainDeptCore).toFixed(2);
    },
    getTypeTeamData:function(){
      const that=this;
      getAction(this.url.queryTeamCodeInfo,{projectType:this.projectBuildData.projectTypeSubCategory}).then(res=>{
        if(!res.result){
          return;
        }
        if(res.result.deptTeamData&&res.result.deptTeamData.length>0){
          res.result.deptTeamData.forEach(item=>{
            that.deptOptions.push({value:item.code,label:item.name});
          });
        }
        if(res.result.teamResponsibilityData&&res.result.teamResponsibilityData.length>0){
          res.result.teamResponsibilityData.forEach(item=>{
            that.responsibilityOptions.push({value:item.name,label:item.name});
          });
        }
        if(res.result.teamRoleData&&res.result.teamRoleData.length>0){
          res.result.teamRoleData.forEach(item=>{
            that.roleOptions.push({value:item.name,label:item.name});
          });
        }
        if(res.result.specialtyTypeData&&res.result.specialtyTypeData.length>0){
          res.result.specialtyTypeData.forEach(item=>{
            that.specialtyTypeOptions.push({value:item.name,label:item.name});
          });
        }
        if(res.result.specialtyTechnologyData&&res.result.specialtyTechnologyData.length>0){
          res.result.specialtyTechnologyData.forEach(item=>{
            that.specialtyTechnologyOptions.push({value:item.name,label:item.name});
          });
        }
      })
    },
    getTeamGpaData:function(){
      getAction(this.url.queryTeamGpaByProjectType,{projectType:this.projectBuildData.projectTypeSubCategory}).then(res=>{
        let teamGpaData=res.result||[];
        if(teamGpaData.length>0){
          let teamGpaArr=teamGpaData.filter(t=>t.projectRoleName==='模块');
          if(teamGpaArr.length>0){
            this.teamGpaData=teamGpaArr[0];
          }
          let managerGpaArr=teamGpaData.filter(t=>t.projectRoleName==='项目经理');
          if(managerGpaArr.length>0){
            this.managerGpaData=managerGpaArr[0];
          }
        }
      })
    },
    getCountModeData(){
      getAction(this.talentSearch.codeInfoUrl,{type:this.projectBuildData.projectTypeSubCategory+'类项目等级计算方式'}).then(res=>{
        if(res.result&&res.result.length>0){
          this.countModeData=res.result[0].name.trim();
        }else{
          this.countModeData="X";
        }
      })
    },
    getSelUserData(){
      getAction(this.userSel.tabUrl,{pageSize:10000}).then(res=>{
        if(res.code==0){
          this.userSel.userSelectData=res.result.records;
        }else{
          this.$message.warning('用户选择数据加载失败:'+res.message);
        }
      })
    },
    sendInvitation(){
      const that=this;
      if(this.checkTeam()){
        this.projectBuildData.teamList=this.teamListData;
        this.projectBuildData.sendInvitationUserList=this.selectedTeamRowKeys;
        if(this.selectedTeamRowKeys.length===0){
          Modal.confirm({title: '您没有选择团队成员，确定对全员发送邀约？',
            onOk() {
              that.doSendInvitation();
            },
            onCancel() {},
          });
        }else{
          Modal.confirm({title: '确定对选择的成员发送邀约？',
            onOk() {
              that.doSendInvitation();
            },
            onCancel() {},
          });
        }
      }
    },
    doSendInvitation(){
      const that=this;
      postAction(this.url.sendInvitation,this.projectBuildData).then(res=>{
        if(res.success){
          that.$message.success('发送成功');
          that.getTeamListData();
        }else{
          that.$message.warning('发送失败:'+res.message);
        }
      })
    },
    async saveTeam(){
      const that=this;
      let success=0;
      if((this.checkTeam(false)&&this.checkDept(false)) && this.checkFourManager()){
        if(await this.doSave()){
          success=1;
          // that.$message.success('保存成功');
          if(!that.changeId){
            that.getTeamListData();
            // that.getDeptListData();
          }
        }
      }
      return success;
    },
    async doSubmit(){
      if(!this.btnShow||!this.loadingDone){
        return 2;
      }
      let success=0;
      if(this.projectBuildData.status===1&&!this.checkGradePointDispatch(true)){
        return await this.saveTeam();
      }
      if(this.projectBuildData.status>1&&!this.checkGradePointDispatchAudit(true)){
        return await this.saveTeam();
      }

      if(this.checkTeam(true)&&this.checkDept(true) && this.checkFourManager()){
        if(await this.doSave()){
          success=2
        }
      }else{
        return await this.saveTeam();
      }
      return success;
    },
    async doSave(){
      const that=this;
      let success=false;
      this.btnLoading=true;
      if(this.changeId){
        let changeData={projectBuildId:this.projectBuildId,changeId:this.changeId,teamList:this.teamListData,deptList:this.deptListData};
        changeData.deptCost = this.projectBuildData.deptCost;
        changeData.teamGradePointAudit=this.projectBuildData.teamGradePointAudit;
        changeData.teamGradePointBasicAudit=this.projectBuildData.teamGradePointBasicAudit;
        changeData.teamGradePointCoreAudit=this.projectBuildData.teamGradePointCoreAudit;
        changeData.deptGradePointAudit=this.projectBuildData.deptGradePointAudit;
        changeData.deptGradePointBasicAudit=this.projectBuildData.deptGradePointBasicAudit;
        changeData.deptGradePointCoreAudit=this.projectBuildData.deptGradePointCoreAudit;
        await postActionAsync(this.url.saveChangeTeam,changeData).then(res=>{
          that.btnLoading=false;
          if(res.success){
            that.$message.success('保存成功');
            success=true;
          }else{
            that.$message.warning('保存失败:'+res.message);
          }
        }).catch(res=>{
          that.btnLoading=false;
          this.$message.warning('保存失败:'+res.message);
        });
      }else{
        this.projectBuildData.teamList=this.teamListData;
        this.projectBuildData.deptList=this.deptListData;
        this.projectBuildData.projectRewardApplyId=this.projectRewardApplyId;
        await postActionAsync(this.url.saveTeam,this.projectBuildData).then(res=>{
          that.btnLoading=false;
          if(res.success){
            that.$message.success('保存成功');
            success=true;
            if(that.projectRewardApplyId && that.projectBuildData.projectClass == '40'){
                  that.reloadOpener();
              }
          }else{
            that.$message.warning('保存失败:'+res.message);
          }
        }).catch(res=>{
          that.btnLoading=false;
          this.$message.warning('保存失败:'+res.message);
        });
      }
      return success;
    },
    reloadOpener(){
      if(window.parentReload){
        window.parentReload("{}")
      }else{
        window.opener.location.reload();
      }
    },
    checkTeam(submit){
      if(this.projectBuildData.status===1){
        return this.checkAddTeam(submit);
      }else{
        return this.checkAuditTeam(submit);
      }
    },
    checkFourManager(data) {
      data = data ? data : [];
      let list = [...data,...this.teamListData]
      let num = 0;
      for(let i=0;i<list.length;i++){
        let member=list[i];
         if(member.memberRoleName.indexOf('经理')>=0){
            num = num + 1;
          }
      }
      if (num> 4) {
         this.$message.warning('团队成员不能超过4个项目经理/副经理');
        return false;
      }
      return true;
    },
    checkAddTeam(submit){
      if(isNaN(parseFloat(this.projectBuildData.teamGradePoint))){
        this.$message.warning('请正确输入核心团队分配X绩点');
        return false;
      }
      if(isNaN(parseFloat(this.projectBuildData.teamGradePointBasic))){
        this.$message.warning('请正确输入核心团队分配Y绩点');
        return false;
      }
      if(isNaN(parseFloat(this.projectBuildData.teamGradePointCore))){
        this.$message.warning('请正确输入核心团队分配核心力值');
        return false;
      }

      let managerUser=[];
      let managerTotal=0,managerBasicTotal=0,managerCoreTotal=0;
      let memberTotal=0,deptTotal=0,coreTotal=0;
      for(let i=0;i<this.teamListData.length;i++){
        let member=this.teamListData[i];

        member.memberGradePoint=!member.memberGradePoint||member.memberGradePoint===''?0:member.memberGradePoint;
        if(isNaN(parseFloat(member.memberGradePoint))){
          this.$message.warning('请正确输入团队成员 ['+member.memberRealName+"] X绩点");
          return false;
        }
        member.deptGradePoint=!member.deptGradePoint||member.deptGradePoint===''?0:member.deptGradePoint;
        if(isNaN(parseFloat(member.deptGradePoint))){
          this.$message.warning('请正确输入团队成员 ['+member.memberRealName+"] Y绩点");
          return false;
        }
        member.coreGradePoint=!member.coreGradePoint||member.coreGradePoint===''?0:member.coreGradePoint;
        if(isNaN(parseFloat(member.coreGradePoint))){
          this.$message.warning('请正确输入团队成员 ['+member.memberRealName+"] 核心力值");
          return false;
        }
        if(submit){
          if(!member.memberRoleName||member.memberRoleName===''||!member.memberResponsibility||member.memberResponsibility===''){
            this.$message.warning('请先把核心团队成员的 [角色]和[主要职责] 填写完整');
            return false;
          }

          memberTotal+=parseFloat(member.memberGradePoint);
          deptTotal+=parseFloat(member.deptGradePoint);
          coreTotal+=parseFloat(member.coreGradePoint);

          if(member.memberRoleName.indexOf('项目经理')>=0||member.memberRoleName.indexOf('项目副经理')>=0){
            managerUser.push(member.memberUserName)
          }
          if(member.memberRoleName.indexOf('项目经理')>=0&&(!member.status||member.status<3)){
            managerTotal+=parseFloat(member.memberGradePoint);
            managerBasicTotal+=parseFloat(member.deptGradePoint);
            managerCoreTotal=parseFloat(member.coreGradePoint);
          }
        }
      }
      if(submit){
        if(memberTotal.toFixed(2)!==parseFloat(this.projectBuildData.teamGradePoint).toFixed(2)){
          this.$message.warning('核心团队X总绩点与分配的X绩点不相等');
          return false;
        }
        if(deptTotal.toFixed(2)!==parseFloat(this.projectBuildData.teamGradePointBasic).toFixed(2)){
          this.$message.warning('核心团队Y总绩点与分配的Y绩点不相等');
          return false;
        }
        if(coreTotal.toFixed(2)!==parseFloat(this.projectBuildData.teamGradePointCore).toFixed(2)){
          this.$message.warning('核心团队核心力值与分配的核心力值不相等');
          return false;
        }
        if(managerUser.indexOf(this.projectBuildData.createUserId)<0&&this.projectBuildData.projectClass != '90'&&!this.changeId&&!this.projectRewardApplyId){
          this.$message.warning('项目创建人必须为项目经理或者项目副经理');
          return false;
        }
        let msg=this.countModeData==='X'?'X绩点':this.countModeData==='X+Y'?'X+Y绩点':'核心力值';
        let judgeTotal=this.countModeData==='X'?parseFloat(this.projectBuildData.projectGradePoint):
          this.countModeData==='X+Y'?(parseFloat(this.projectBuildData.projectGradePoint)+parseFloat(this.projectBuildData.projectGradePointBasic)):
            parseFloat(this.projectBuildData.projectGradePointCore);
        if(this.teamGpaData){
          let scaleCeiling = parseFloat(this.teamGpaData.scaleCeiling);
          let scaleFloor = parseFloat(this.teamGpaData.scaleFloor);
          let judgeTeamPoint=this.countModeData==='X'?parseFloat(this.projectBuildData.teamGradePoint):
            this.countModeData==='X+Y'?(parseFloat(this.projectBuildData.teamGradePoint)+parseFloat(this.projectBuildData.teamGradePointBasic)):
              parseFloat(this.projectBuildData.teamGradePointCore);
          let present=judgeTeamPoint/judgeTotal;
          if (scaleCeiling > 0 && present > scaleCeiling.toFixed(2)) {
            this.$message.warning('核心团队分配'+msg+'超出提取比例上限');
            return false;
          }
          if (scaleFloor > 0 && present < scaleFloor.toFixed(2)) {
            this.$message.warning('核心团队分配'+msg+'低于提取比例下限');
            return false;
          }
        }
        if(this.managerGpaData){
          let scaleCeiling = parseFloat(this.managerGpaData.scaleCeiling);
          let scaleFloor = parseFloat(this.managerGpaData.scaleFloor);
          let judgeManagerPoint=this.countModeData==='X'?managerTotal:this.countModeData==='X+Y'?(managerTotal+managerBasicTotal):managerCoreTotal;

          let present=judgeManagerPoint/judgeTotal;
          if (scaleCeiling > 0 && present > scaleCeiling.toFixed(2)) {
            this.$message.warning('核心团队项目经理分配'+msg+'总数超出提取比例上限');
            return false;
          }
          if (scaleFloor > 0 && present < scaleFloor.toFixed(2)) {
            this.$message.warning('核心团队项目经理分配'+msg+'总数低于提取比例下限');
            return false;
          }
        }
      }

      return true;
    },
    checkAuditTeam(submit){
      if(isNaN(parseFloat(this.projectBuildData.teamGradePointAudit))){
        this.$message.warning('请正确输入核心团队分配X绩点');
        return false;
      }
      if(isNaN(parseFloat(this.projectBuildData.teamGradePointBasicAudit))){
        this.$message.warning('请正确输入核心团队分配Y绩点');
        return false;
      }
      if(isNaN(parseFloat(this.projectBuildData.teamGradePointCoreAudit))){
        this.$message.warning('请正确输入核心团队分配核心力值');
        return false;
      }

      let managerUser=[];
      let managerTotal=0,managerBasicTotal=0,managerCoreTotal=0;
      let memberTotal=0,deptTotal=0,coreTotal=0;
      for(let i=0;i<this.teamListData.length;i++){
        let member=this.teamListData[i];

        member.memberGradePointAudit=!member.memberGradePointAudit||member.memberGradePointAudit===''?0:member.memberGradePointAudit;
        if(isNaN(parseFloat(member.memberGradePointAudit))){
          this.$message.warning('请正确输入团队成员 ['+member.memberRealName+"] X绩点");
          return false;
        }
        member.deptGradePointAudit=!member.deptGradePointAudit||member.deptGradePointAudit===''?0:member.deptGradePointAudit;
        if(isNaN(parseFloat(member.deptGradePointAudit))){
          this.$message.warning('请正确输入团队成员 ['+member.memberRealName+"] Y绩点");
          return false;
        }
        member.coreGradePointAudit=!member.coreGradePointAudit||member.coreGradePointAudit===''?0:member.coreGradePointAudit;
        if(isNaN(parseFloat(member.coreGradePointAudit))){
          this.$message.warning('请正确输入团队成员 ['+member.memberRealName+"] 核心力值");
          return false;
        }

        if(submit){
          if(!member.memberRoleName||member.memberRoleName===''||!member.memberResponsibility||member.memberResponsibility===''){
            this.$message.warning('请先把核心团队成员的 [角色]和[主要职责] 填写完整');
            return false;
          }

          memberTotal+=parseFloat(member.memberGradePointAudit);
          deptTotal+=parseFloat(member.deptGradePointAudit);
          coreTotal+=parseFloat(member.coreGradePointAudit);
          if(member.memberRoleName.indexOf('项目经理')>=0||member.memberRoleName.indexOf('项目副经理')>=0){
            managerUser.push(member.memberUserName)
          }
          if(member.memberRoleName.indexOf('项目经理')>=0&&(!member.status||member.status<3)){
            managerTotal+=parseFloat(member.memberGradePointAudit);
            managerBasicTotal+=parseFloat(member.deptGradePointAudit);
            managerCoreTotal=parseFloat(member.coreGradePointAudit);
          }
        }

      }
      if(submit){
        if(memberTotal.toFixed(2)!==parseFloat(this.projectBuildData.teamGradePointAudit).toFixed(2)){
          this.$message.warning('核心团队X总绩点与分配的X绩点不相等');
          return false;
        }
        if(deptTotal.toFixed(2)!==parseFloat(this.projectBuildData.teamGradePointBasicAudit).toFixed(2)){
          this.$message.warning('核心团队Y总绩点与分配的Y绩点不相等');
          return false;
        }
        if(coreTotal.toFixed(2)!==parseFloat(this.projectBuildData.teamGradePointCoreAudit).toFixed(2)){
          this.$message.warning('核心团队核心力值与分配的核心力值不相等');
          return false;
        }
        if(managerUser.indexOf(this.projectBuildData.createUserId)<0&&this.projectBuildData.projectClass != '90'&&!this.changeId&&!this.projectRewardApplyId){
          this.$message.warning('项目创建人必须为项目经理或者项目副经理');
          return false;
        }
        let msg=this.countModeData==='X'?'X绩点':this.countModeData==='X+Y'?'X+Y绩点':'核心力值';
        let judgeTotal=this.countModeData==='X'?parseFloat(this.xChangePoint!=null?this.xChangePoint:this.projectBuildData.projectAuditGradePoint):
          this.countModeData==='X+Y'?(parseFloat(this.xChangePoint!=null?this.xChangePoint:this.projectBuildData.projectAuditGradePoint)+parseFloat(this.yChangePoint!=null?this.yChangePoint:this.projectBuildData.projectAuditGradePointBasic)):
            parseFloat(this.coreChangePoint!=null?this.coreChangePoint:this.projectBuildData.projectAuditGradePointCore);
        if(this.teamGpaData){
          let scaleCeiling = parseFloat(this.teamGpaData.scaleCeiling);
          let scaleFloor = parseFloat(this.teamGpaData.scaleFloor);
          let judgeTeamPoint=this.countModeData==='X'?parseFloat(this.projectBuildData.teamGradePointAudit):
            this.countModeData==='X+Y'?(parseFloat(this.projectBuildData.teamGradePointAudit)+parseFloat(this.projectBuildData.teamGradePointBasicAudit)):
              parseFloat(this.projectBuildData.teamGradePointCoreAudit);
          let present=judgeTeamPoint/judgeTotal;
          if (scaleCeiling > 0 && present > scaleCeiling.toFixed(2)) {
            this.$message.warning('核心团队分配'+msg+'超出提取比例上限');
            return false;
          }
          if (scaleFloor > 0 && present < scaleFloor.toFixed(2)) {
            this.$message.warning('核心团队分配'+msg+'低于提取比例下限');
            return false;
          }
        }
        if(this.managerGpaData){
          let scaleCeiling = parseFloat(this.managerGpaData.scaleCeiling);
          let scaleFloor = parseFloat(this.managerGpaData.scaleFloor);
          let judgeManagerPoint=this.countModeData==='X'?managerTotal:this.countModeData==='X+Y'?(managerTotal+managerBasicTotal):managerCoreTotal;

          let present=judgeManagerPoint/judgeTotal;
          if (scaleCeiling > 0 && present > scaleCeiling.toFixed(2)) {
            this.$message.warning('核心团队项目经理分配'+msg+'总数超出提取比例上限');
            return false;
          }
          if (scaleFloor > 0 && present < scaleFloor.toFixed(2)) {
            this.$message.warning('核心团队项目经理分配'+msg+'总数低于提取比例下限');
            return false;
          }
        }
      }

      return true;
    },
    checkDept(submit){
      if(this.projectBuildData.status===1){
        return this.checkAddDept(submit);
      }else{
        return this.checkAuditDept(submit);
      }
    },
    checkAddDept(submit){
      if(isNaN(parseFloat(this.projectBuildData.deptGradePoint))){
        this.$message.warning('请正确输入协作模块分配X绩点');
        return false;
      }
      if(isNaN(parseFloat(this.projectBuildData.deptGradePointBasic))){
        this.$message.warning('请正确输入协作模块分配Y绩点');
        return false;
      }
      if(isNaN(parseFloat(this.projectBuildData.deptGradePointCore))){
        this.$message.warning('请正确输入协作模块分配核心力值');
        return false;
      }

      let teamTotal=0,deptTotal=0,coreTotal=0;
      for(let i=0;i<this.deptListData.length;i++){
        let member=this.deptListData[i];

        member.teamGradePoint=!member.teamGradePoint||member.teamGradePoint===''?0:member.teamGradePoint;
        if(isNaN(parseFloat(member.teamGradePoint))){
          this.$message.warning('请正确输入协作模块 ['+member.projectTeamName+"] X绩点");
          return false;
        }
        member.deptGradePoint=!member.deptGradePoint||member.deptGradePoint===''?0:member.deptGradePoint;
        if(isNaN(parseFloat(member.deptGradePoint))){
          this.$message.warning('请正确输入协作模块 ['+member.projectTeamName+"] Y绩点");
          return false;
        }
        member.coreGradePoint=!member.coreGradePoint||member.coreGradePoint===''?0:member.coreGradePoint;
        if(isNaN(parseFloat(member.coreGradePoint))){
          this.$message.warning('请正确输入协作模块 ['+member.projectTeamName+"] 核心力值");
          return false;
        }
        for(let i=0;i<this.deptListData.length;i++){
          let dept=this.deptListData[i];
          if(dept.deptName===''){
            continue;
          }
          let checkDeptList=this.deptListData.filter(d=>d.projectTeamCode===dept.projectTeamCode&&d.deptName===dept.deptName);
          if(checkDeptList.length>1){
            this.$message.warning('协作模块【'+dept.projectTeamName+'】具体部门【'+dept.deptName+'】重复');
            return false;
          }
        }
        if(submit){
          if(!member.deptName||member.deptName===''||!member.leaderRealName||member.leaderRealName===''||!member.requiredCompletionTime||member.requiredCompletionTime===''){
            this.$message.warning('请先把协作模块的 [具体部门]、[部门主管]和[要求完成时间] 填写完整');
            return false;
          }
          teamTotal+=parseFloat(member.teamGradePoint);
          deptTotal+=parseFloat(member.deptGradePoint);
          coreTotal+=parseFloat(member.coreGradePoint);
        }
      }
      if(submit) {
        if (teamTotal.toFixed(2) !== parseFloat(this.projectBuildData.deptGradePoint).toFixed(2)) {
          this.$message.warning('协作模块X总绩点与分配的X绩点不相等');
          return false;
        }
        if (deptTotal.toFixed(2) !== parseFloat(this.projectBuildData.deptGradePointBasic).toFixed(2)) {
          this.$message.warning('协作模块Y总绩点与分配的Y绩点不相等');
          return false;
        }
        if (coreTotal.toFixed(2) !== parseFloat(this.projectBuildData.deptGradePointCore).toFixed(2)) {
          this.$message.warning('协作模块总核心力值与分配的核心力值不相等');
          return false;
        }
      }
      return true;
    },
    checkAuditDept(submit){
      if(isNaN(parseFloat(this.projectBuildData.deptGradePointAudit))){
        this.$message.warning('请正确输入协作模块分配X绩点');
        return false;
      }
      if(isNaN(parseFloat(this.projectBuildData.deptGradePointBasicAudit))){
        this.$message.warning('请正确输入协作模块分配Y绩点');
        return false;
      }
      if(isNaN(parseFloat(this.projectBuildData.deptGradePointCoreAudit))){
        this.$message.warning('请正确输入协作模块分配核心力值');
        return false;
      }

      let teamTotal=0,deptTotal=0,coreTotal=0;
      for(let i=0;i<this.deptListData.length;i++){
        let member=this.deptListData[i];

        member.teamGradePointAudit=!member.teamGradePointAudit||member.teamGradePointAudit===''?0:member.teamGradePointAudit;
        if(isNaN(parseFloat(member.teamGradePointAudit))){
          this.$message.warning('请正确输入协作模块 ['+member.projectTeamName+"] X绩点");
          return false;
        }
        member.deptGradePointAudit=!member.deptGradePointAudit||member.deptGradePointAudit===''?0:member.deptGradePointAudit;
        if(isNaN(parseFloat(member.deptGradePointAudit))){
          this.$message.warning('请正确输入协作模块 ['+member.projectTeamName+"] Y绩点");
          return false;
        }
        member.coreGradePointAudit=!member.coreGradePointAudit||member.coreGradePointAudit===''?0:member.coreGradePointAudit;
        if(isNaN(parseFloat(member.coreGradePointAudit))){
          this.$message.warning('请正确输入协作模块 ['+member.projectTeamName+"] 核心力值");
          return false;
        }
        if(submit){
          if(!member.deptName||member.deptName===''||!member.leaderRealName||member.leaderRealName===''){
            this.$message.warning('请先把协作模块的 [具体部门]和[部门主管] 填写完整');
            return false;
          }
          teamTotal+=parseFloat(member.teamGradePointAudit);
          deptTotal+=parseFloat(member.deptGradePointAudit);
          coreTotal+=parseFloat(member.coreGradePointAudit);
        }
      }
      if(submit) {
        if (teamTotal.toFixed(2) !== parseFloat(this.projectBuildData.deptGradePointAudit).toFixed(2)) {
          this.$message.warning('协作模块X总绩点与分配的X绩点不相等');
          return false;
        }
        if (deptTotal.toFixed(2) !== parseFloat(this.projectBuildData.deptGradePointBasicAudit).toFixed(2)) {
          this.$message.warning('协作模块Y总绩点与分配的Y绩点不相等');
          return false;
        }
        if (coreTotal.toFixed(2) !== parseFloat(this.projectBuildData.deptGradePointCoreAudit).toFixed(2)) {
          this.$message.warning('协作模块总核心力值与分配的核心力值不相等');
          return false;
        }
      }
      return true;
    },
    specialtyTypeChange(value){
      console.log(value);
      this.talentSearch.specialtyType=value;
      let type=value+"-工序";
      let that=this;
      that.specialtyOptions=[];
      getAction(this.talentSearch.codeInfoUrl,{type:type}).then(res=>{
        if(res.result){
          res.result.forEach(item=>{
            that.specialtyOptions.push({value:item.name,label:item.name});
          });
        }
      })
    },
    specialtyTechnologyChange(value){
      console.log(value);
      this.talentSearch.specialtyTechnology=value;
      let type=value+"-专业技术领域";
      let that=this;
      that.technologyOptions=[];
      getAction(this.talentSearch.codeInfoUrl,{type:type}).then(res=>{
        if(res.result){
          res.result.forEach(item=>{
            that.technologyOptions.push({value:item.name,label:item.name});
          });
        }
      })
    },
    specialtyChange(value){
      console.log(value);
      this.talentSearch.specialty=value.join(",");
    },
    technologyChange(value){
      console.log(value);
      this.talentSearch.technology=value.join(",");
    },
    searchTalent(){
      let that=this;
      postAction(this.talentSearch.searchTalentUrl,this.talentSearch).then(res=>{
        if(!res.result){
          that.technologyOptions=[];
        }else{
          this.talentSearch.talentData=res.result;
        }
      })
    },
    doAddTalent(){
      if(this.talentSearch.selectedTalentRows.length==0){
        this.$message.warning("请先选择要要添加的成员");
        return;
      }
      let that=this;
      for(let i=0;i<this.talentSearch.selectedTalentRows.length;i++){
        let talent=this.talentSearch.selectedTalentRows[i];
        if(!this.checkTeamMember(talent.username)){
          this.$message.warning('核心团队已存在成员 ['+talent.realname+"]");
          return;
        }
      }
      this.talentSearch.selectedTalentRows.forEach(function(item){
        that.addTeamListData(item);
      });
      this.initTalentSearch();
    },
    cancelAddTalent(){
      this.initTalentSearch();
    },
    initTalentSearch(){
      this.talentSearch.showAddTalent=false;
      this.talentSearch.specialtyTechnology='';
      this.talentSearch.technology='';
      this.talentSearch.specialtyType='';
      this.talentSearch.specialty='';
      this.talentSearch.name = '';
      this.talentSearch.talentData=[];
      this.talentSearch.selectedTalentRows=[];
    },
    addTeamMember(){
      /*if (!!this.projectBuildData.projectClass && (this.projectBuildData.projectClass === '30' || this.projectBuildData.projectClass === '40'
      || this.projectBuildData.projectClass === '50' || this.projectBuildData.projectClass === '60' || this.projectBuildData.projectClass === '70'
      || this.projectBuildData.projectClass === '80')) {
        this.userSel.selectPersonType='team';
        // this.userSel.selectUserData=[];
        // this.userSel.visible=true;
        this.personLimit=0;
        this.$refs.personSelect.doSelect();
      }else{
        this.talentSearch.showAddTalent=true;
      }*/
      this.userSel.selectPersonType='team';
      this.personLimit=0;
      this.$refs.personSelect.doSelect();
    },
    selectLeaderUser(record){
      this.userSel.selectPersonType='dept';
      this.userSel.currentRecord=record;
      // this.userSel.selectUserData=[];
      // this.userSel.visible=true;
      this.personLimit=1;
      this.$refs.personSelect.doSelect();
    },
    delTeamMember(){
      let that=this;
      if(this.selectedTeamRowKeys.length==0){
        this.$message.warning("请先选择要删除的团队成员");
        return;
      }
      Modal.confirm({title: '是否确认删除？',
        onOk() {
          that.selectedTeamRowKeys.forEach(function(item){
            that.doDelTeamMember(item);
          });
          that.$message.success("删除成功，保存生效");
        },
        onCancel() {},
      });
    },
    doDelTeamMember(memberUserName){
      for(let i=0;i<this.teamListData.length;i++){
        let member=this.teamListData[i];
        if(member.memberUserName==memberUserName){
          this.teamListData.splice(i,1);
          break;
        }
      }
    },
    replaceTeamMember(){
      if(this.selectedTeamRowKeys.length!=1){
        this.$message.warning("请先选择一位要替换的团队成员");
        return;
      }
      this.userSel.selectPersonType='teamReplace';
      this.personLimit=1;
      this.$refs.personSelect.doSelect();
    },
    delDeptMember(){
      let that=this;
      if(this.selectedDeptRowKeys.length==0){
        this.$message.warning("请先选择要删除的协作模块");
        return;
      }
      Modal.confirm({title: '是否确认删除？',
        onOk() {
          that.selectedDeptRowKeys.sort(function(a,b){
            return b-a;
          });
          that.selectedDeptRowKeys.forEach(function(item){
            that.doDelDeptMember(item);
          });
          that.$message.success("删除成功，保存生效");
          that.selectedDeptRowKeys=[];
        },
        onCancel() {},
      });
    },
    doDelDeptMember(rowKey){
      for(let i=0;i<this.deptListData.length;i++){
        let member=this.deptListData[i];
        if(member.rowKey==rowKey){
          this.deptListData.splice(i,1);
          break;
        }
      }
    },
    /*----------选择协作模块-------------*/
    openSelectDept(){
      this.showAddDept=true;
    },
    doAddDept(){
      if(!this.selectAddDeptData.key){
        this.$message.warning('请先选择协作模块');
        return;
      }
      /*let checkData=this.deptListData.filter(item =>{
        return item.projectTeamCode === this.selectAddDeptData.key;
      });
      if(checkData&&checkData.length>0){
        this.$message.warning('协作模块已有['+this.selectAddDeptData.label+"] 的记录，不能重复添加");
        return;
      }*/
      var fileBusId = 'file_'+new Date().getTime()+Math.ceil(Math.random()*100000000);
      let addDeptData={
        rowKey:++this.deptRowKey,
        projectTeamCode:this.selectAddDeptData.key,
        projectTeamName:this.selectAddDeptData.label,
        leaderUserName:'',
        leaderRealName:'',
        deptId:'',
        deptName:'',
        jobContent:'',
        teamGradePoint:0,
        deptGradePoint:0,
        coreGradePoint:0,
        teamGradePointAudit:0,
        deptGradePointAudit:0,
        coreGradePointAudit:0,
        fileBusId:fileBusId,
        fileAmount:0
      };
      this.deptListData.push(addDeptData);
      this.showAddDept=false;
    },
    cancelAddDept(){
      this.showAddDept=false;
    },
    /*----------------------------*/
    checkGradePointDispatch(submit){
      //检查输入是否合法
      let checkResult=true;
      if(!this.checkGradePoint("teamGradePoint",'请正确输入主导项目的核心团队分配X绩点')){
        checkResult= false;
      }
      if(checkResult&&!this.checkGradePoint("teamGradePointBasic",'请正确输入主导项目的核心团队分配Y绩点')){
        checkResult= false;
      }
      if(checkResult&&!this.checkGradePoint("teamGradePointCore",'请正确输入主导项目的核心团队分配核心力值')){
        checkResult= false;
      }
      if(checkResult&&!this.checkGradePoint("deptGradePoint",'请正确输入协作模块分配X绩点')){
        checkResult= false;
      }
      if(checkResult&&!this.checkGradePoint("deptGradePointBasic",'请正确输入协作模块分配Y绩点')){
        checkResult= false;
      }
      if(checkResult&&!this.checkGradePoint("deptGradePointCore",'请正确输入协作模块分配核心力值')){
        checkResult= false;
      }
      if(checkResult){
        this.countTeamRemain();
        this.countDeptRemain();
      }

      let dispatchGradePointX=parseFloat(this.projectBuildData.teamGradePoint)+parseFloat(this.projectBuildData.deptGradePoint);
      let dispatchGradePointY=parseFloat(this.projectBuildData.teamGradePointBasic)+parseFloat(this.projectBuildData.deptGradePointBasic);
      let dispatchGradePointCore=parseFloat(this.projectBuildData.teamGradePointCore)+parseFloat(this.projectBuildData.deptGradePointCore);

      let remainGradePointX=parseFloat(this.projectBuildData.projectGradePoint)-dispatchGradePointX;
      let remainGradePointY=parseFloat(this.projectBuildData.projectGradePointBasic)-dispatchGradePointY;
      let remainGradePointCore=parseFloat(this.projectBuildData.projectGradePointCore)-dispatchGradePointCore;
      this.dispatchGradePointX=dispatchGradePointX.toFixed(2);
      this.dispatchGradePointY=dispatchGradePointY.toFixed(2);
      this.dispatchGradePointCore=dispatchGradePointCore.toFixed(2);
      this.remainGradePointX=remainGradePointX.toFixed(2)<0?'超出'+(-remainGradePointX.toFixed(2)):Math.abs(remainGradePointX).toFixed(2);
      this.remainGradePointY=remainGradePointY.toFixed(2)<0?'超出'+(-remainGradePointY.toFixed(2)):Math.abs(remainGradePointY).toFixed(2);
      this.remainGradePointCore=remainGradePointCore.toFixed(2)<0?'超出'+(-remainGradePointCore.toFixed(2)):Math.abs(remainGradePointCore).toFixed(2);

      if(remainGradePointX.toFixed(2)<0){
        this.$message.warning('分配X绩点总和超出项目X绩点');
        return false;
      }
      if(submit&&remainGradePointX.toFixed(2)>0){
        this.$message.warning('项目X绩点没有分配完成');
        return false;
      }
      if(remainGradePointY.toFixed(2)<0){
        this.$message.warning('分配Y绩点总和超出项目Y绩点');
        return false;
      }
      if(submit&&remainGradePointY.toFixed(2)>0){
        this.$message.warning('项目Y绩点没有分配完成');
        return false;
      }
      if(remainGradePointCore.toFixed(2)<0){
        this.$message.warning('分配核心力值总和超出项目核心力值');
        return false;
      }
      if(submit&&remainGradePointCore.toFixed(2)>0){
        this.$message.warning('项目核心力值没有分配完成');
        return false;
      }
      return true;
    },
    checkGradePointDispatchAudit(submit){
      //检查输入是否合法
      if(!this.checkGradePoint("teamGradePointAudit",'请正确输入主导项目的核心团队分配X绩点')){
        return false;
      }
      if(!this.checkGradePoint("teamGradePointBasicAudit",'请正确输入主导项目的核心团队分配Y绩点')){
        return false;
      }
      if(!this.checkGradePoint("teamGradePointCoreAudit",'请正确输入主导项目的核心团队分配核心力值')){
        return false;
      }
      if(!this.checkGradePoint("deptGradePointAudit",'请正确输入协作模块分配X绩点')){
        return false;
      }
      if(!this.checkGradePoint("deptGradePointBasicAudit",'请正确输入协作模块分配Y绩点')){
        return false;
      }
      if(!this.checkGradePoint("deptGradePointCoreAudit",'请正确输入协作模块分配核心力值')){
        return false;
      }
      let dispatchGradePointX=parseFloat(this.projectBuildData.teamGradePointAudit)+parseFloat(this.projectBuildData.deptGradePointAudit);
      let dispatchGradePointY=parseFloat(this.projectBuildData.teamGradePointBasicAudit)+parseFloat(this.projectBuildData.deptGradePointBasicAudit);
      let dispatchGradePointCore=parseFloat(this.projectBuildData.teamGradePointCoreAudit)+parseFloat(this.projectBuildData.deptGradePointCoreAudit);

      let remainGradePointX=parseFloat(this.xChangePoint!=null?this.xChangePoint:this.projectBuildData.projectAuditGradePoint)-dispatchGradePointX;
      let remainGradePointY=parseFloat(this.yChangePoint!=null?this.yChangePoint:this.projectBuildData.projectAuditGradePointBasic)-dispatchGradePointY;
      let remainGradePointCore=parseFloat(this.coreChangePoint!=null?this.coreChangePoint:this.projectBuildData.projectAuditGradePointCore)-dispatchGradePointCore;
      this.dispatchGradePointX=dispatchGradePointX.toFixed(2);
      this.dispatchGradePointY=dispatchGradePointY.toFixed(2);
      this.dispatchGradePointCore=dispatchGradePointCore.toFixed(2);
      this.remainGradePointX=remainGradePointX.toFixed(2)<0?'超出'+(-remainGradePointX.toFixed(2)):Math.abs(remainGradePointX).toFixed(2);
      this.remainGradePointY=remainGradePointY.toFixed(2)<0?'超出'+(-remainGradePointY.toFixed(2)):Math.abs(remainGradePointY).toFixed(2);
      this.remainGradePointCore=remainGradePointCore.toFixed(2)<0?'超出'+(-remainGradePointCore.toFixed(2)):Math.abs(remainGradePointCore).toFixed(2);

      this.countTeamRemain();
      this.countDeptRemain();
      if(remainGradePointX.toFixed(2)<0){
        this.$message.warning('分配X绩点总和超出项目X绩点');
        return false;
      }
      if(submit&&remainGradePointX.toFixed(2)>0){
        this.$message.warning('项目X绩点没有分配完成');
        return false;
      }
      if(remainGradePointY.toFixed(2)<0){
        this.$message.warning('分配Y绩点总和超出项目Y绩点');
        return false;
      }
      if(submit&&remainGradePointY.toFixed(2)>0){
        this.$message.warning('项目Y绩点没有分配完成');
        return false;
      }
      if(remainGradePointCore.toFixed(2)<0){
        this.$message.warning('分配核心力值总和超出项目核心力值');
        return false;
      }
      if(submit&&remainGradePointCore.toFixed(2)>0){
        this.$message.warning('项目核心力值没有分配完成');
        return false;
      }

      return true;
    },
    checkGradePoint(target,errMsg){
      let checkResult=true;
      let jsStr='if(!this.projectBuildData.#teamGradePoint#||this.projectBuildData.#teamGradePoint#===""){' +
        '        this.projectBuildData.#teamGradePoint#=0;' +
        '      }else{' +
        '        let teamGradePoint=parseFloat(this.projectBuildData.#teamGradePoint#);' +
        '        if(isNaN(teamGradePoint)){' +
        '          checkResult= false;' +
        '        }else{' +
        '        this.projectBuildData.#teamGradePoint#=teamGradePoint.toFixed(2);' +
        '      }}';
      jsStr=jsStr.replace(/#teamGradePoint#/g,target);
      eval(jsStr);
      if(!checkResult){
        this.$message.warning(errMsg);
      }
      return checkResult;
    },
    checkTeamX(record){
      if(record.memberGradePoint===''){
        record.memberGradePoint=0;
      }else{
        let gradePoint=parseFloat(record.memberGradePoint);
        if(isNaN(gradePoint)){
          this.$message.warning("请正确输入团队成员 ["+record.memberRealName+"] X绩点");
          return;
        }
        let totalX=0;
        this.teamListData.forEach(function(item){
          if(!item.status||item.status<3){
            totalX+=!item.memberGradePoint||item.memberGradePoint===''?0:parseFloat(item.memberGradePoint);
          }
        });
        this.remainData.remainTeamX=parseFloat(this.projectBuildData.teamGradePoint)-totalX;
        this.remainData.remainTeamX=this.remainData.remainTeamX.toFixed(2)<0?'超出'+(-this.remainData.remainTeamX.toFixed(2)):Math.abs(this.remainData.remainTeamX).toFixed(2);
        if(totalX-parseFloat(this.projectBuildData.teamGradePoint)>0.01){
          this.$message.warning("成员X绩点总和大于分配的X绩点");
        }
      }
    },
    checkTeamY(record){
      if(record.deptGradePoint===''){
        record.deptGradePoint=0;
      }else{
        let gradePoint=parseFloat(record.deptGradePoint);
        if(isNaN(gradePoint)){
          this.$message.warning("请正确输入团队成员 ["+record.memberRealName+"] Y绩点");
          return;
        }
        let totalX=0;
        this.teamListData.forEach(function(item){
          if(!item.status||item.status<3){
            totalX+=!item.deptGradePoint||item.deptGradePoint===''?0:parseFloat(item.deptGradePoint);
          }
        });
        this.remainData.remainTeamY=parseFloat(this.projectBuildData.teamGradePointBasic)-totalX;
        this.remainData.remainTeamY=this.remainData.remainTeamY.toFixed(2)<0?'超出'+(-this.remainData.remainTeamY.toFixed(2)):Math.abs(this.remainData.remainTeamY).toFixed(2);
        if(totalX-parseFloat(this.projectBuildData.teamGradePointBasic)>0.01){
          this.$message.warning("成员Y绩点总和大于分配的Y绩点");
        }
      }
    },
    checkTeamCore(record){
      if(record.coreGradePoint===''){
        record.coreGradePoint=0;
      }else{
        let gradePoint=parseFloat(record.coreGradePoint);
        if(isNaN(gradePoint)){
          this.$message.warning("请正确输入团队成员 ["+record.memberRealName+"] 核心力值");
          return;
        }
        let totalX=0;
        this.teamListData.forEach(function(item){
          if(!item.status||item.status<3){
            totalX+=!item.coreGradePoint||item.coreGradePoint===''?0:parseFloat(item.coreGradePoint);
          }
        });
        this.remainData.remainTeamCore=parseFloat(this.projectBuildData.teamGradePointCore)-totalX;
        this.remainData.remainTeamCore=this.remainData.remainTeamCore.toFixed(2)<0?'超出'+(-this.remainData.remainTeamCore.toFixed(2)):Math.abs(this.remainData.remainTeamCore).toFixed(2);
        if(totalX-parseFloat(this.projectBuildData.teamGradePointCore)>0.01){
          this.$message.warning("成员核心力值总和大于分配的核心力值");
        }
      }
    },
    checkTeamXAudit(record){
      if(record.memberGradePointAudit===''){
        record.memberGradePointAudit=0;
      }else{
        let gradePoint=parseFloat(record.memberGradePointAudit);
        if(isNaN(gradePoint)){
          this.$message.warning("请正确输入团队成员 ["+record.memberRealName+"] X绩点");
          return;
        }
        let totalX=0;
        this.teamListData.forEach(function(item){
          totalX+=!item.memberGradePointAudit||item.memberGradePointAudit===''?0:parseFloat(item.memberGradePointAudit);
        });
        this.remainData.remainTeamX=parseFloat(this.projectBuildData.teamGradePointAudit)-totalX;
        this.remainData.remainTeamX=this.remainData.remainTeamX.toFixed(2)<0?'超出'+(-this.remainData.remainTeamX.toFixed(2)):Math.abs(this.remainData.remainTeamX).toFixed(2);
        if(totalX-parseFloat(this.projectBuildData.teamGradePointAudit)>0.01){
          this.$message.warning("成员X绩点总和大于分配的X绩点");
        }
      }
    },
    checkTeamYAudit(record){
      if(record.deptGradePointAudit===''){
        record.deptGradePointAudit=0;
      }else{
        let gradePoint=parseFloat(record.deptGradePointAudit);
        if(isNaN(gradePoint)){
          this.$message.warning("请正确输入团队成员 ["+record.memberRealName+"] Y绩点");
          return;
        }
        let totalX=0;
        this.teamListData.forEach(function(item){
          totalX+=!item.deptGradePointAudit||item.deptGradePointAudit===''?0:parseFloat(item.deptGradePointAudit);
        });
        this.remainData.remainTeamY=parseFloat(this.projectBuildData.teamGradePointBasicAudit)-totalX;
        this.remainData.remainTeamY=this.remainData.remainTeamY.toFixed(2)<0?'超出'+(-this.remainData.remainTeamY.toFixed(2)):Math.abs(this.remainData.remainTeamY).toFixed(2);
        if(totalX-parseFloat(this.projectBuildData.teamGradePointBasicAudit)>0.01){
          this.$message.warning("成员Y绩点总和大于分配的Y绩点");
        }
      }
    },
    checkTeamCoreAudit(record){
      if(record.coreGradePointAudit===''){
        record.coreGradePointAudit=0;
      }else{
        let gradePoint=parseFloat(record.coreGradePointAudit);
        if(isNaN(gradePoint)){
          this.$message.warning("请正确输入团队成员 ["+record.memberRealName+"] 核心力值");
          return;
        }
        let totalX=0;
        this.teamListData.forEach(function(item){
          totalX+=!item.coreGradePointAudit||item.coreGradePointAudit===''?0:parseFloat(item.coreGradePointAudit);
        });
        this.remainData.remainTeamCore=parseFloat(this.projectBuildData.teamGradePointCoreAudit)-totalX;
        this.remainData.remainTeamCore=this.remainData.remainTeamCore.toFixed(2)<0?'超出'+(-this.remainData.remainTeamCore.toFixed(2)):Math.abs(this.remainData.remainTeamCore).toFixed(2);
        if(totalX-parseFloat(this.projectBuildData.teamGradePointCoreAudit)>0.01){
          this.$message.warning("成员核心力值总和大于分配的核心力值");
        }
      }
    },
    checkDeptX(record){
      if(record.teamGradePoint===''){
        record.teamGradePoint=0;
      }else{
        let gradePoint=parseFloat(record.teamGradePoint);
        if(isNaN(gradePoint)){
          this.$message.warning("请正确输入模块 ["+record.projectTeamName+"] X绩点");
          return;
        }
        let totalX=0;
        this.deptListData.forEach(function(item){
          totalX+=!item.teamGradePoint||item.teamGradePoint===''?0:parseFloat(item.teamGradePoint);
        });
        this.remainData.remainDeptX=parseFloat(this.projectBuildData.deptGradePoint)-totalX;
        this.remainData.remainDeptX=this.remainData.remainDeptX.toFixed(2)<0?'超出'+(-this.remainData.remainDeptX.toFixed(2)):Math.abs(this.remainData.remainDeptX).toFixed(2);
        if(totalX-parseFloat(this.projectBuildData.deptGradePoint)>0.01){
          this.$message.warning("协作模块X绩点总和大于分配的X绩点");
        }
      }
    },
    checkDeptY(record){
      if(record.deptGradePoint===''){
        record.deptGradePoint=0;
      }else{
        let gradePoint=parseFloat(record.deptGradePoint);
        if(isNaN(gradePoint)){
          this.$message.warning("请正确输入模块 ["+record.projectTeamName+"] Y绩点");
          return;
        }
        let totalX=0;
        this.deptListData.forEach(function(item){
          totalX+=!item.deptGradePoint||item.deptGradePoint===''?0:parseFloat(item.deptGradePoint);
        });
        this.remainData.remainDeptY=parseFloat(this.projectBuildData.deptGradePointBasic)-totalX;
        this.remainData.remainDeptY=this.remainData.remainDeptY.toFixed(2)<0?'超出'+(-this.remainData.remainDeptY.toFixed(2)):Math.abs(this.remainData.remainDeptY).toFixed(2);
        if(totalX-parseFloat(this.projectBuildData.deptGradePointBasic)>0.01){
          this.$message.warning("协作模块Y绩点总和大于分配的Y绩点");
        }
      }
    },
    checkDeptCore(record){
      if(record.coreGradePoint===''){
        record.coreGradePoint=0;
      }else{
        let gradePoint=parseFloat(record.coreGradePoint);
        if(isNaN(gradePoint)){
          this.$message.warning("请正确输入模块 ["+record.projectTeamName+"] 核心力值");
          return;
        }
        let totalX=0;
        this.deptListData.forEach(function(item){
          totalX+=!item.coreGradePoint||item.coreGradePoint===''?0:parseFloat(item.coreGradePoint);
        });
        this.remainData.remainDeptCore=parseFloat(this.projectBuildData.deptGradePointCore)-totalX;
        this.remainData.remainDeptCore=this.remainData.remainDeptCore.toFixed(2)<0?'超出'+(-this.remainData.remainDeptCore.toFixed(2)):Math.abs(this.remainData.remainDeptCore).toFixed(2);
        if(totalX-parseFloat(this.projectBuildData.deptGradePointCore)>0.01){
          this.$message.warning("协作模块核心力值总和大于分配的核心力值");
        }
      }
    },
    checkDeptXAudit(record){
      if(record.teamGradePointAudit===''){
        record.teamGradePointAudit=0;
      }else{
        let gradePoint=parseFloat(record.teamGradePointAudit);
        if(isNaN(gradePoint)){
          this.$message.warning("请正确输入模块 ["+record.projectTeamName+"] X绩点");
          return;
        }
        let totalX=0;
        this.deptListData.forEach(function(item){
          totalX+=!item.teamGradePointAudit||item.teamGradePointAudit===''?0:parseFloat(item.teamGradePointAudit);
        });
        this.remainData.remainDeptX=parseFloat(this.projectBuildData.deptGradePointAudit)-totalX;
        this.remainData.remainDeptX=this.remainData.remainDeptX.toFixed(2)<0?'超出'+(-this.remainData.remainDeptX.toFixed(2)):Math.abs(this.remainData.remainDeptX).toFixed(2);
        if(totalX-parseFloat(this.projectBuildData.deptGradePointAudit)>0.01){
          this.$message.warning("协作模块X绩点总和大于分配的X绩点");
        }
      }
    },
    checkDeptYAudit(record){
      if(record.deptGradePointAudit===''){
        record.deptGradePointAudit=0;
      }else{
        let gradePoint=parseFloat(record.deptGradePointAudit);
        if(isNaN(gradePoint)){
          this.$message.warning("请正确输入模块 ["+record.projectTeamName+"] Y绩点");
          return;
        }
        let totalX=0;
        this.deptListData.forEach(function(item){
          totalX+=!item.deptGradePointAudit||item.deptGradePointAudit===''?0:parseFloat(item.deptGradePointAudit);
        });
        this.remainData.remainDeptY=parseFloat(this.projectBuildData.deptGradePointBasicAudit)-totalX;
        this.remainData.remainDeptY=this.remainData.remainDeptY.toFixed(2)<0?'超出'+(-this.remainData.remainDeptY.toFixed(2)):Math.abs(this.remainData.remainDeptY).toFixed(2);
        if(totalX-parseFloat(this.projectBuildData.deptGradePointBasicAudit)>0.01){
          this.$message.warning("协作模块Y绩点总和大于分配的Y绩点");
        }
      }
    },
    checkDeptCoreAudit(record){
      if(record.coreGradePointAudit===''){
        record.coreGradePointAudit=0;
      }else{
        let gradePoint=parseFloat(record.coreGradePointAudit);
        if(isNaN(gradePoint)){
          this.$message.warning("请正确输入模块 ["+record.projectTeamName+"] 核心力值");
          return;
        }
        let totalX=0;
        this.deptListData.forEach(function(item){
          totalX+=!item.coreGradePointAudit||item.coreGradePointAudit===''?0:parseFloat(item.coreGradePointAudit);
        });
        this.remainData.remainDeptCore=parseFloat(this.projectBuildData.deptGradePointCoreAudit)-totalX;
        this.remainData.remainDeptCore=this.remainData.remainDeptCore.toFixed(2)<0?'超出'+(-this.remainData.remainDeptCore.toFixed(2)):Math.abs(this.remainData.remainDeptCore).toFixed(2);
        if(totalX-parseFloat(this.projectBuildData.deptGradePointCoreAudit)>0.01){
          this.$message.warning("协作模块核心力值总和大于分配的核心力值");
        }
      }
    },
    /*---------用户选择方法----------*/
    setPersonSelResult(result){
      if(this.userSel.selectPersonType==='dept'){
        this.userSel.currentRecord.leaderUserName=result[0].username;
        this.userSel.currentRecord.leaderRealName=result[0].realname;
      }else if(this.userSel.selectPersonType==='teamReplace'){
        let item=result[0];
        if(!this.checkReplaceTeamMember(item.username)){
          this.$message.warning('核心团队已存在成员 ['+item.realname+"]");
          return;
        }
        this.doReplaceTeamMember(item);
      }else{
        for(let i=0;i<result.length;i++){
          let item=result[i];
          if(!this.checkTeamMember(item.username)){
            this.$message.warning('核心团队已存在成员 ['+item.realname+"]");
            return;
          }
          this.addTeamListData(item);
        }
      }
    },
    checkReplaceTeamMember(memberUserName){
      let checkData=this.teamListData.filter(item=>item.memberUserName===memberUserName&&item.memberUserName!==this.selectedTeamRowKeys[0]);
      return !checkData||checkData.length===0;
    },
    checkTeamMember(memberUserName){
      let checkData=this.teamListData.filter(item=>item.memberUserName===memberUserName);
      return !checkData||checkData.length===0;
    },
    addTeamListData(row){
      let rowData = {};
      rowData.id = '';
      rowData.projectTeamCode = "1";
      rowData.memberUserName = row.username;
      rowData.memberRealName =  row.realname;
      rowData.memberDeptId = row.deptId;
      rowData.memberDeptName =row.deptName;
      rowData.memberRoleName = '';
      rowData.memberResponsibility = '';
      rowData.teamGradePoint = '';
      rowData.memberGradePoint = 0;
      rowData.deptGradePoint = 0;
      rowData.coreGradePoint = 0;
      rowData.memberExpectReward = 0;
      rowData.coreExpectReward = 0;
      rowData.memberGradePointAudit = 0;
      rowData.deptGradePointAudit = 0;
      rowData.coreGradePointAudit = 0;
      rowData.memberExpectRewardAudit = 0;
      rowData.coreExpectRewardAudit = 0;
      rowData.status = 0;
      this.teamListData.push(rowData);
    },
    doReplaceTeamMember(row){
      const that=this;
      this.teamListData.forEach(function(item){
        if(item.memberUserName===that.selectedTeamRowKeys[0]){
          item.memberUserName = row.username;
          item.memberRealName =  row.realname;
          item.memberDeptId = row.deptId;
          item.memberDeptName =row.deptName;
        }
      });
      this.selectedTeamRowKeys=[];
    },
    /*------------导入团队成员----------------*/
    importTeamMember(){
      this.excelVisible=true;
    },
    exportTeamMember(){
       let param = {projectBuildId:this.projectBuildId};

      console.log("导出参数",param)
      this.exportLoading = true;
      downloadFileLink('/projectBuildTeam/exportXls','项目团队导出.xls', param,{type: 'application/vnd.ms-excel'}).then((data)=>{
        this.exportLoading = false;
      })
    },
    importMemberManday(){
      debugger
      this.saveType = 2 ;
      this.exportXlsTemplateUrl='/导入成本.xls',
      this.exportXlsTemplateRequestUrl='/projectBuildTeam/exportXlsManDay?projectBuildId='+this.projectBuildId
      this.columnsExcel = this.columnsExcelManday;
      this.excelVisible = true;
    } ,
    handleFeedback(){
      this.$refs.mandayRef.add();
    } ,
    handleOkExcel:function(data){

      if(!data||data.length===0){
        this.$message.warning('请粘贴数据再导入');
        return;
      }

      if (this.saveType == 1){
        debugger
        this.excelDataSource = [];
        for (let index = 0; index < data.length; index++) {
          const element = data[index];
          if(element.memberUserName===''){
            this.$message.warning('成员账号必填');
            return;
          }
          if(element.memberResponsibility.length>200){
            this.$message.warning('主要职责不能超过200个字符');
            return;
          }
          let checkData = this.teamListData.filter(item => {
            return item.memberUserName === element.memberUserName;
          });
          if(checkData&&checkData.length>0){
            this.$message.warning('已存在团队成员 [ '+element.memberUserName+' ]，不能重复添加');
            return;
          }
          if(element.memberGradePoint!==''){
            let checkAmount=parseFloat(element.memberGradePoint);
            if(isNaN(checkAmount)){
              this.$message.warning('请正确输入团队成员 [ '+element.memberUserName+' ] X绩点');
              return;
            }
            element.memberGradePoint=checkAmount.toFixed(2);
          }else{
            element.memberGradePoint=0;
          }

          if(element.deptGradePoint!==''){
            let checkAmount=parseFloat(element.deptGradePoint);
            if(isNaN(checkAmount)){
              this.$message.warning('请正确输入团队成员 [ '+element.memberUserName+' ] Y绩点');
              return;
            }
            element.deptGradePoint=checkAmount.toFixed(2);
          }else{
            element.deptGradePoint=0;
          }
          if(element.coreGradePoint!==''){
            let checkAmount=parseFloat(element.coreGradePoint);
            if(isNaN(checkAmount)){
              this.$message.warning('请正确输入团队成员 [ '+element.memberUserName+' ] 核心力值');
              return;
            }
            element.coreGradePoint=checkAmount.toFixed(2);
          }else{
            element.coreGradePoint=0;
          }
        }
        this.excelDataSource = data;
        if (!this.checkFourManager(data)) {
          return ;
        }
        //数据验证
        this.excelConfirmLoading = true;
        if(this.changeId){
          let changeData = { projectBuildId:this.projectBuildId , changeId:this.changeId , teamList:this.excelDataSource };
          postAction(this.url.importChangeTeam,changeData).then(res => {
            this.excelConfirmLoading = false;
            if(res.code === 200){
              this.teamListData=res.result;
              this.excelVisible = false;
              this.$message.success("导入成功");
            }else{
              this.$message.warning('操作异常:'+res.message);
            }
          }).catch(res=>{
            this.excelConfirmLoading = false;
            this.$message.warning('操作异常:'+res.message);
          })
        }else{
          this.projectBuildData.teamList=this.excelDataSource;
          postAction(this.url.addBatch,this.projectBuildData).then(res => {
            this.excelConfirmLoading = false;
            if(res.code === 200){

              this.excelVisible = false;
              this.$message.success("导入成功");
              this.getTeamListData();
            }else{
              this.$message.warning('操作异常:'+res.message);
            }
          }).catch(res=>{
            this.excelConfirmLoading = false;
            this.$message.warning('操作异常:'+res.message);
          })
        }
      }
     else
     {
        this.excelDataSource = data;
        this.doSaveManday( this.excelDataSource )
     }
    },
    doSaveManday(data){

      let mandayData = {};
      this.$set(this.projectBuildData , 'id' , this.projectBuildId)
      this.$set(this.projectBuildData , 'projectBuildMandayList' , data)
      this.$set(this.projectBuildData , 'changeId' , this.changeId);
      postAction(this.url.importMandays , this.projectBuildData).then( res => {
        debugger
        if (res.code == 200){
          this.$message.success(res.message)
          this.excelVisible = false;
        }
        else {
          this.$message.warning(res.message)
        }
      })
    },
    handleCancelExcel:function(){
      this.excelVisible = false;
    },
    /*---------------------------------------*/
    onSelectTeamChange(selectedRowKeys) {
      console.log('selectedRowKeys changed: ', selectedRowKeys);
      this.selectedTeamRowKeys = selectedRowKeys;
    },
    onSelectTalentChange(selectedRowKeys,selectedRows) {
      console.log('selectedRowKeys changed: ', selectedRowKeys);
      this.talentSearch.selectedTalentRowKeys = selectedRowKeys;
      this.talentSearch.selectedTalentRows = selectedRows;
    },
    onSelectDeptChange(selectedRowKeys) {
      console.log('selectedRowKeys changed: ', selectedRowKeys);
      this.selectedDeptRowKeys = selectedRowKeys;
    },
    convertToChangePoint(){
      const that=this;
      Modal.confirm({title: '确定使用变更后绩点按比例进行一键折算？',
        onOk() {
          that.btnLoading=true;
          let changePointData={
            id:that.projectBuildId,
            projectGradePoint:that.xChangePoint,
            projectGradePointBasic:that.yChangePoint,
            projectGradePointCore:that.coreChangePoint
          };
          postAction(that.url.convertToChangePoint,changePointData).then(res => {
            that.btnLoading = false;
            if(res.code === 200){
              that.$message.success("折算成功");
              that.getChangeTeamData();
            }else{
              that.$message.warning('操作异常:'+res.message);
            }
          }).catch(res=>{
            that.btnLoading = false;
            that.$message.warning('操作异常:'+res.message);
          })
        },
        onCancel() {},
      });
    }
  }
}
</script>
<style lang="less">
.tooltip_class {
  max-width: 600px !important;
}
</style>
<style lang="less" scoped>
/deep/ .ant-modal-close-x{
  font-size: 20px;
}
/deep/ .ant-btn-primary{
  background: #4095e4;
}
/deep/ .ant-table-tbody .ant-input{
  border-radius: unset;
  border: unset;
}
/deep/.ant-table-tbody .ant-table-row td{
  padding-top: 10px;
  padding-bottom: 10px;
}
/deep/ .ant-btn{
  height: 30px;
  border-radius: 2px;
  margin-right: 10px;
}
/deep/ .ant-table-thead > tr > th {
  background: #dadee9 !important;
}
/deep/.ant-table-thead > tr:first-child > th:first-child,/deep/ .ant-table table{
  border-radius: unset;
  line-height: 1;
}
/deep/ .ant-badge-count {
  line-height: 16px;
}
.teamFrom{
  border: 1px solid #e6e6e6;
  background-color: #fff;
  padding-bottom: 20px;
  .header{
    border-bottom: 1px solid #e6e6e6;
    display: flex;
    padding: 30px 0 0 25px;
  }
  .projectGoal{
    margin: 0 25px;
    padding:30px 0;
    border-bottom: 1px solid #e6e6e6;
    .Xgoal,.Ygoal{
      list-style: none;
      display: flex;
      padding: 0;
      li{
        margin-right: 30px;
        width: 150px;
      }
    }
  }
  .content{
    padding: 30px 25px;
    .title{
      border-left: 3px solid #47a4fa;
      padding: 0 10px;
    }
    .printGoal{
      list-style: none;
      display: flex;
      justify-content: flex-start;
      align-items: center;
      flex-wrap:wrap;
      padding: 20px 0 10px;
      li{
        width: fit-content;
        margin-right: 30px;
        display: flex;
        align-items: center;
        span{
          white-space: nowrap;
        }
      }
    }
    .teamSelected{
      .team-control{
        margin-bottom: 15px;
      }
    }
  }
  .btn{
    display: flex;
    justify-content: center;
    margin-top: 30px;
  }
}
.info-list{
  display: flex;
  flex-wrap: wrap;
  border-bottom: 1px dashed #ebebeb;
  >li{
    width: 100%;
    height: 25px;
    display: flex;
    align-items: center;
    >img{
      margin-right: 5px;
    }
    .list-title{
      font-weight: 900;
      white-space: nowrap;
    }
  }
}
.talent-title{
  font-weight: 900;
  width: 110px;
  text-align: right;
  line-height: 30px;
}
.ant-row{
  margin-bottom: 15px;
}
.ant-col{
  display: flex !important;
}

/deep/ .ant-transfer-list .ant-btn-primary{
  color: #bbb;
}
/deep/ .ant-transfer-list:first-of-type .ant-transfer-list-header-selected{
  display: none;
}
/deep/ .ant-modal-content{
  border-radius: 15px;
}
/deep/ .ant-modal-title,/deep/ .ant-modal-footer{
  text-align: center;
}
/deep/ .ant-transfer-operation .ant-btn-primary{
  background-color: #f5f5f5 !important;
}
/deep/ .ant-modal-header{
  border-radius: 15px 15px 0 0;
  background-image: linear-gradient(90deg, #15b1ff 0%,#1158c9 100%);
}
/deep/ .ant-modal-title{
  color: #fff;
}
/deep/.ant-table-placeholder{
  z-index: unset;
}
</style>